RabbitMQ and Drupal, a perfect match

A while back, I needed an AMQP (RabbitMQ) implementation for Drupal. As usual, I browsed for existing contrib modules and, sure enough, a few popped up:

But after careful inspection, none of the above did what I wanted them to do 🤓. That’s why I decided to create my own implementation.

The modules I provided basically contain 3 main things:

  • Worker: A specific class that processes a message, also handles failures in case it could not process the message
  • Queue: A class that represents a RabbitMQ queue and allows for messages to be pushed to the corresponding queue. Each queue is linked to a worker
  • Consumer: Process that consumes a specific queue and its messages. Each queue can have zero or more consumers

The above classes make for a basic framework that allows you to

  • Define queues and workers
  • Push messages to queues
  • Consume queues with a drush command or a background process

This is all explained in great detail on the README page of the repository that contains all the (example) code. Fork, edit and use the code as you see fit, but as always, git the repo a ⭐️ when you do.

Happy queueing and consuming!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store