Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to consume the message in Laravel #75

Open
priyadarshiniMuthuraman opened this issue Oct 14, 2019 · 4 comments
Open

How to consume the message in Laravel #75

priyadarshiniMuthuraman opened this issue Oct 14, 2019 · 4 comments
Labels

Comments

@priyadarshiniMuthuraman

Hi,

I am using this package to publish and consume the message using RabbitMQ in a Microservices based application. I am publishing the message in service and trying to consume the same in another service.

The documentation is pretty clear on the code to consume the published message in the queue. However, in the traditional Laravel queue process, we would describe the process to be performed inside the handle() method. And call the php artisan queue:work command to execute the queue.

But here in the documentation, the code is clear to consume the message but How to consume the message and execute the same with an artisan command is confusing.

where would I write the code below code in Laravel application and listen to it in production server:

Amqp::consume('queue-name', function ($message, $resolver) {
    		
   var_dump($message->body);

   $resolver->acknowledge($message);
        
});
@stevenklar
Copy link
Collaborator

Create a laravel artisan command and start to consume. You will of course need to run the command and handle the keep alive yourself. This library does not provide you with any boilerplate for this.

@Lincolnbiancard
Copy link

@stevenklar Hey, how you doing?
You can show us an example, I’ve read several forums and still can’t consume a queue of an api other than a standard api. :(

@HassanElZarkawy
Copy link

@Lincolnbiancard +1

@ni-bschmitt
Copy link

ni-bschmitt commented Nov 3, 2021

First create a command as described here: https://laravel.com/docs/8.x/artisan#command-structure
Then register the command as described here: https://laravel.com/docs/8.x/artisan#registering-commands

Inside the handle method of the command please put the code from above:

Amqp::consume('queue-name', function ($message, $resolver) {
    		
   var_dump($message->body);

   $resolver->acknowledge($message);
        
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants