The Laravel Synchronous Queue
Sync queue options run your queue synchronously on your dev platform so you can develop and debug your work, then switch the queue platform you use later.
Join the DZone community and get the full member experience.Join For Free
Using queues for asynchronous processing is one of my favorite tricks for offloading hard work from web servers. When working with Laravel recently I was pleased to find that it supports beanstalkd out of the box. I've got opinions about frameworks with Opinions but I did find one thing I really liked in the way Laravel uses queues: the sync queue option that runs your queue synchronously on your development platform so you can develop and debug your work, then switch the queue platform you use later.
It's quite tricky to debug Laravel "Jobs" as they call the worker code — if errors occur, they don't show up in the general output. You can use
error_log() and see that output, but if there's a PHP error, you won't see that error. However you can configure the
.env to be
sync queue type is not asynchronous at all — instead of putting the job onto your chosen queue backend, it goes right ahead and processes the job in the current thread of execution. This completely defeats the object of using a queue but is a brilliant approach for debugging how the data passes from the dispatching context (where the data is put into the job and onto a queue) to the worker context (where the job comes back off the queue and actually gets processed) and how the job is processed.
For development use, it's a nice feature, but do take care to enable your "real" queue configuration when deploying to a production environment so that you get the advantage of the queues. There are some good queueing services available for your cloud applications — specifically for Laravel, look at Laravel Horizon which is Redis with nicer dashboards attached.
Published at DZone with permission of Lorna Mitchell, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Which Is Better for IoT: Azure RTOS or FreeRTOS?
RAML vs. OAS: Which Is the Best API Specification for Your Project?
What to Pay Attention to as Automation Upends the Developer Experience
4 Expert Tips for High Availability and Disaster Recovery of Your Cloud Deployment