Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Eleven Labs Blog:
RabbitMQ: Publish, Consume, and Retry Messages
Feb 03, 2017 @ 12:53:06

On the Eleven Labs blog they're posted a tutorial showing you how to integrate RabbitMQ functionality into your Symfony-based application making use of a few handy tools that do some of the heavy lifting for you and how messages are handled (and what to do when they error).

RabbitMQ is a message broker, allowing to process things asynchronously. There’s already an article written about it, if you’re not familiar with RabbitMQ.

What I’d like to talk to you about is the lifecycle of a message, with error handling. Everything in a few lines of code. Therefore, we’re going to configure a RabbitMQ virtual host, publish a message, consume it and retry publication if any error occurs.

They use the RabbitMQ admin toolkit and Swarrot packages to get the job done. First up is the configuration of the tools, creating a default_vhost.yml file defining a queue and setting up the exchanges and parameters for the default route ("/"). They show an example of what the RabbitMQ UI looks like with this new exchange up and working and how to get more information about this "default" queue. Next up is the consumption and publication of messages. They include an example app/config/config.yml file that defines some settings the Swarrot library (via the SwarrotBundle) needs to understand the connections, consumers and type of provider to use. Finally he shows the configuration so it all knows how to publish messages and a quick example of PHP code that sends a simple string message to be handled by the RabbitMQ workers. The post ends with a bit more configuration and some examples of how to handle errors in this Swarrot/RabbitMQ Admin Toolkit setup and making use of some middleware to help with message retries and number of attempts.

tagged: tutorial rabbitmq symfony bundle swarrot configuration publish consume retry error

Link: http://blog.eleven-labs.com/en/rabbitmq-publish-consume-retry-messages/