I'm using sqs queue in my laravel. Right now I have successsfully pushed my queue job to sqs server as shown in the picture below :
The problem is, the message is never got executed. So how to process this message on SQS...??
Thanks a lot
I think you forgot to run the queue daemon.
Try to run php artisan queue:listen in the project folder.
Related
I try to dispatch a job on my local dev machine.
I setup my .env and queue config ; QUEUE_CONNECTION=database
I also did the migrate :
php artisan queue:table
php artisan migrate
Then create my job something like : myjob::dispatchNow();
And finally run my worker: php artisan queue:work
With all that the code launch and execute well but not the job. The job is not created in the database jobs table. (nor in faield_jobs
Is I am missing any step?
Do I need something else on my local machine to run jobs queue?
Thanks for any help.
You are using synchronous dispatching by using myjob::dispatchNow(). The database does not need to be involved as it runs the job during the same request and your queue worker never knows about it. It is equivalent to having QUEUE_DRIVER=sync.
If you use myjob::dispatch() before you start the queue worker, you will see the job in your database.
I am using Laravel forge with Redis as the queue driver.
I have updated the code for my application to send push notifications a few times over, but the notifications sent are as in the old code.
Changing the queue driver to database, sends the notifications as per the latest updates. However when I switched it back to Redis, it still shows old version of the notification.
I have done "FLUSHALL" via redis-cli, but it didn't fix it.
Also I use Laravel Horizon to manage queues.
How I can fix this? Thanks in advance.
Edit: Other thing I noticed was all code driven dispatches were queued on Redis. I have listed the solution in the answer in the hopes it would help someone else.
What I received from Forge support:
Hello,
There might be a worker that's stuck you can try and run php artisan
horizon:purge which should kill all rogue worker processes, and then
restart the daemon. It's advised to run the purge command in your
deployment script to make sure all stale processes are killed.
-- Mohamed Said forge#laravel.com
However this how I got it sorted:
php artisan horizon:terminate
php artisan queue:restart
And then the code was working properly
Stop redis, Stop Horizon workers. Start redis and then start horizon workers.
But before these all clear cache.
I had similar problem and in my case it was just the matter of restart all the services.
I am a newbie with laravel, and I am implementing email verification system with queue in laravel.
What happening is, when I execute php artisan queue:work it works fine, when it needs to triggers, but when I quit the queue and re-execute, it doesn't trigger anymore.
I tried php artisan queue:restart, but it didn't do the trick.
What could be causing this please?
Queue will only work as long as queue:work is still running or executing in console. Any jobs fired after this has stopped will not be executed. You get to see your jobs in the database if you are using database driver as your queue driver . I use Supervisor to keep queue:work running at the backround
I have worked with Queues in laravel which will Queue the Jobs. php artisan queue:work command will take jobs in queue and process it.
But, i want to use pure queue without a job, One process will push itnto queue and another process read from queue and process it.
Eg, in a login api request, i will push just email id to queue. There will be a background process running(not queue:work) which can read the queue enties(list of emails) and do some action with it.
So the i need a custom worker which can read from queue.
How to do this in laravel?
Its not possible directly. https://github.com/laravel/framework/issues/17083
By design laravel doesnt allow this. You can however try to implement a custom solution.
I'm using Laravel forge and I've setup a queue called mail. It handles all mails in my application. When I set the QUEUE_DRIVER to sync in my .env file all mails are being send as expected. But when I use the QUEUE_DRIVER=beanstalkd mails do not send.
When I listen for the queue php artisan queue:work --queue=mail I can see that the jobs are being handled.
Already restarted the queue and recreated it. But nothing seems to work. When I look into my jobs table there are no errors. What on earth could be going on?