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

Tuleap Blog:
How we replaced RabbitMQ by Redis
Feb 09, 2018 @ 16:44:44

On the Tuleap blog there's an article posted showing how they made the switch from RabbitMQ to Redis in their PHP application.

There are various places in Tuleap were message queues are needed but the primary one is to run jobs in background. Historically it was for all system related stuff (creating users, git/svn repositories, etc) that required special unix permissions that we were not eager to grant to a web app.

[...] More recently we add a need to share events across servers, for distributed Tuleap setup for instance. Our good old system was no longer able to deal with that because we needed a real queue management that works across servers. We choose RabbitMQ because we were looking for a queue system, PHP support quite decent and tutorials were good. However, we had to setup a quite complicated queue system.

The post outlines the exchange to exchange binding system they created and includes the code use to make the RabbitMQ-based system work. Then they introduce Redis and how, when they learned about RPOPLPUSH, decided to make the switch. The code for this replacement is also included.

tagged: rabbitmq redis queue system replacement tutorial

Link: https://blog.tuleap.org/how-we-replaced-rabbitmq-redis

Ibrahim Gunduz:
Sending Logs From Symfony Applications To GrayLog Through RabbitMQ
Sep 29, 2017 @ 16:17:10

On his Medium.com site ?brahim Gündüz has posted a tutorial showing you how to send logs from Symfony to Graylog via RabbitMQ, making use of backend queues to handle moving log information into the Graylog instance.

Message Queues are indispensable tools of the systems which is under high load. You can split your systems to small pieces and provide communication between each other through message queue services.

If your system happens by many pieces it means you have so many log entries which is coming from multiple application instances in same time. So you should scale your logging system like how you scaled your application also. Otherwise, your application may go down because of your logging system might be bottleneck.

You can use message queue systems to avoid this trouble.

He starts by helping you install the Composer dependencies required for the RabbitMQ interface and defining the configuration in Symfony to make the connection to the queue. With this in place he moves over to the RabbitMQ side and sets up the queue and exchange to handle the incoming log information. He then creates a LoggingTestCommand command to test out sending the logs to the queue and shows the setup of Graylog to read from that queue and pull in the information automatically.

tagged: symfony tutorial rabbitmq graylog log integration

Link: https://medium.com/@ibrahimgunduz34/sending-logs-from-symfony-applications-to-graylog-through-rabbitmq-4735aebfce4b

Playing with RabbitMQ, PHP and node
Feb 20, 2017 @ 17:51:58

In the latest post to his site Gonzalo Ayuso shares some of the results of his "playing with RabbitMQ, PHP and node", creating a queue system that both languages could talk to easily.

I need to use RabbitMQ in one project. I’m a big fan of Gearman, but I must admit Rabbit is much more powerful. In this project I need to handle with PHP code and node, so I want to build a wrapper for those two languages. I don’t want to re-invent the wheel so I will use existing libraries (php-amqplib and amqplib for node).

Basically I need to use three things: First I need to create exchange channels to log different actions. I need to decouple those actions from the main code. I also need to create work queues to ensure those works are executed. It doesn’t matter if work is executed later but it must be executed. And finally RPC commands.

He goes through some of the basics of using RabbitMQ , showing the code for each of the languages - pushing a new value into the queue, registering workers, creating Queue builders and using an exchange and receiver to process the message. The post finishes with the last piece in his requirements: creating the functionality to handle RPC commands to get an answer back from the queue.

tagged: rabbitmq node tutorial integration nodejs queue

Link: https://gonzalo123.com/2017/02/20/playing-with-rabbitmq-php-and-node/

Eleven Labs Blog:
RabbitMQ: Publish, Consume, and Retry Messages
Feb 03, 2017 @ 18: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/

SitePoint PHP Blog:
PHP and RabbitMQ: Advanced Examples
Oct 20, 2014 @ 19:19:33

On the SitePoint PHP blog Miguel Ibarra Romero continues his series looking at the use of RabbitMQ with PHP in part two. He builds on the code (and setup) from the first part of the series and gets into some more advanced examples this time.

In part 1 we covered the theory and a simple use case of the AMQP protocol in PHP with RabbitMQ as the broker. Now, let’s dive into some more advanced examples.

The remainder of the post includes two examples of more advanced operations:

  • Example 1: send request to process data asynchronously among several workers
  • Example 2: send RPC requests and expect a reply

Each example includes a diagram of the overall flow of the process, the code to make it happen both for the sender and receiver.

tagged: rabbitmq advanced example tutorial series part2

Link: http://www.sitepoint.com/php-rabbitmq-advanced-examples/

SitePoint PHP Blog:
How to use RabbitMQ with PHP
Oct 17, 2014 @ 17:43:04

The SitePoint PHP blog has published a new tutorial today by Miguel Ibarra Romero introducing you to the RabbitMQ queuing tool and shows you how to use it in PHP-based applications via the php-amqplib library.

AMQP (Advanced Message Queueing Protocol) is a network protocol that can deliver messages from one application endpoint to another application endpoint. It does not care about the platform or language of said applications, as long as they support AMQP. [...] The advantage of having a message broker such as RabbitMQ, and AMQP being a network protocol, is that the producer, the broker, and the consumer can live on different physical/virtual servers on different geographic locations.

With some of the introductions out of the way (common terms, flow of the data, etc) he walks through the installation of the RabbitMQ software on your system. He uses a Ubuntu install, but the commands could be easily ported for other distributions. From there he shows how to install the PHP library and a simple example of a pizza ordering system where orders are sent to be processed offline. Complete code is included to make the "SimpleSender" class and push the request out to the queue. With that working, he also shows how to create a SimpleReceiver class that consumes the data from the queue and sends the data to be processed.

tagged: rabbitmq tutorial introduction installation library phpamqplib

Link: http://www.sitepoint.com/use-rabbitmq-php/

Piotr Pasich:
Rabbit behind the scenes
Oct 01, 2014 @ 17:19:53

In a recent post to his site Piotr Pasich shares an article about using a rabbit behind the scenes - making use of the RabbitMQ queuing system for behind the scenes work in your PHP applications.

In PHP business logic is usually put right in action’s method or just behind it. Hence, every little piece of delaying and long-running code will be processed with a request. The problem is almost undetectable if a user sends an e-mail but with more complex actions it may take a little bit longer than preferred. [...] In this article I would like to make an attempt to present a solution to the very annoying everyday problem that probably many programmers came across in their organisations – deadlocks in databases caused by a vast number of requests in relatively short time. The main aim of this text is to introduce RabbitMQ, which I value as a very functional and practical message broker, to help you solve the queuing problems and decrease the amount of work you would otherwise have to spend on it.

He talks about why message brokers are even needed and how to pick the right one for your project. Then he gets into the "in practice" part of the article, showing the use of RabbitMQ through PHP to save various data to a database when a user is presented with an advertisement. He shows how to create both the producer and consumer objects, making interaction with the queue simpler. His examples are all using the php-amqplib by Alvaro Videla.

tagged: rabbitmq introduction library tutorial message broker producer consumer

Link: http://piotrpasich.com/rabbit-behind-the-scenes/

Brandon Savage:
Consuming RabbitMQ messages with PHP
May 31, 2013 @ 14:15:47

Brandon Savage continues his look at using RabbitMQ and PHP together to queue up requests today in this latest post. In this new part of the series, he focuses on the last piece of the puzzle - consuming the requests in the queue. (Parts one and two)

Once you’ve created a RabbitMQ producer, it’s fairly easy to create a consumer. In fact, the only difference is in exactly what commands you’re using. The connection, envelope, channel and queue declarations are the same. While in RabbitMQ you publish to the exchange, you actually do consume a specific queue. As a result, the commands for consuming are part of the AMQPQueue class.

He shows you how to set up the code to sit in the background and wait for a queue request and how to fetch them in a non-blocking way. He finishes off the post with a look at handling success and error conditions (based on the status of message consumption, not the result of the processing).

tagged: rabbitmq tutorial consume amqp library success failure nonblocking background

Link: http://www.brandonsavage.net/consuming-rabbitmq-messages-with-php

Brandon Savage:
Publishing messages to RabbitMQ with PHP
May 30, 2013 @ 15:09:49

Brandon Savage has posted the second article in his RabbitMQ+PHP series today with a look at publishing messages to the queue. (Part one is here)

Now that we understand the basics behind RabbitMQ, it’s time for us to start working with it. The first step in working with RabbitMQ is to begin sending messages to the exchange so that they can be queued. In RabbitMQ parlance, the “producer” is responsible for “publishing” the messages to the exchange.

He includes the code you'll need to use the AMQP PHP extension to connect with the RabbitMQ server and select a channel. He also shows how to set up an "exchange" and "queue" and bind them to each other. Finally, there's the one line of code that uses the routing key value to push a message into the waiting service.

tagged: rabbitmq publishing message tutorial queue exchange connection

Link: http://www.brandonsavage.net/publishing-messages-to-rabbitmq-with-php

Brandon Savage:
Queuing with RabbitMQ and PHP
May 28, 2013 @ 14:41:39

Brandon Savage has posted a quick overview of working with PHP and RabbitMQ for queuing. This is the first part of a three-part series about using these two technologies together effectively.

There are many times that you want to write background processes and queue up the tasks so that they can be handled in sequential order. There are any number of queues available for software developers, and one that I’ve really taken a liking to is RabbitMQ. Besides the fact that the queue is designed to requeue messages that are unsuccessfully delivered, RabbitMQ is fast and efficient.

He introduces some of the basic concepts behind working with RabbitMQ (like connections and channels) and an "exchange" - the method by which messages are routed. He talks about pushing messages to the exchange to be handled and how you consume the queue for updates. He also links to the various things you'll need to install to start combining these two tools including the AMPQ PECL extension.

tagged: queue rabbitmq ampq pecl install overview series

Link: http://www.brandonsavage.net/queuing-with-rabbitmq-and-php


Trending Topics: