Support the ongoing development of Laravel.io →
posted 10 years ago
Queues
Last updated 2 years ago.
0

Hey @rms2219, you should look how Laravel push the quotes. If you look at the generated JSON, you will find something like:

{"job":"Acme\\Jobs\\PushFilesJob","data":{"file_id":"1"}}

The listener then will find the "job" class and run the fire function.

Does that helps you?

Last updated 2 years ago.
0

@ipalaus, I suppose I should re-phrase my question...Can a Laravel application listen/consume messages from a queue for which it did not push messages to? In other words, can a Laravel app act as ONLY a listener? And if so, how do I configure it to use a particular class to handle the message processing?

Last updated 2 years ago.
0

Yeah, of course it can but Laravel listeners expect a concrete message. A JSON containing the class name (+ data if you want).

Last updated 2 years ago.
0

ipalaus said:

A JSON containing the class name (+ data if you want).

So I can setup the listener like:

php artisan queue:listen {"job" : "PATH\\TO\\MY\\PROCESSOR"}

?

Last updated 2 years ago.
0

No, the queue:listen will listen to the given driver. The driver knows where to fetch the jobs, if it's the Amazon SQS somehow you should push your jobs there (with the 3rd party API) and then just configure the queue to listen there. And just run php artisan queue:listen.

Last updated 2 years ago.
0

ipalaus said:

No, the queue:listen will listen to the given driver. The driver knows where to fetch the jobs, if it's the Amazon SQS somehow you should push your jobs there (with the 3rd party API) and then just configure the queue to listen there. And just run php artisan queue:listen.

Right, so that's what I did. I pushed a message to my SQS queue via Amazon's console. So, there's a job just sitting there in the queue. My problem is, when I run php artisan queue:listen, how can I tell the Laravel app where to send that message once it pulls it from the queue?

Last updated 2 years ago.
0

Are you saying that the message I push to SQS (regardless of where it's being pushed from) needs to be in the format: {"job":"Acme\Jobs\PushFilesJob","data":{"file_id":"1"}}? If so, this makes more sense. I was thinking that all I needed to do was to push data to the queue, and when I set up my listener, I'd make a connection between the listener and the class that processes the message.

Last updated 2 years ago.
0

That's it. You need that payload in SQS.

Last updated 2 years ago.
0

ipalaus said:

That's it. You need that payload in SQS.

Thanks...I've got it now and it's working as expected. Thank you for your help.

Last updated 2 years ago.
0

ipalaus said:

Yeah, of course it can but Laravel listeners expect a concrete message. A JSON containing the class name (+ data if you want).

I am using Laravel 5 to accomplish the same task. My jobs (JSON) are being pushed to a beanstalkd queue from an external entity and I want to setup my Queuing system within my laravel app to just watch the queue and handle jobs from it as and when it is available. Please do help me in doing this.

PS: What should be the exact JSON structure that I need to follow for my jobs to be recognized by my laravel queue listener?

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

rms2219 rms2219 Joined 3 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.