RabbitMQ and Drupal, a perfect match

Robin Ingelbrecht
1 min readMay 10, 2022

--

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!

RabbitMQ logo

--

--

Robin Ingelbrecht

My name is Robin Ingelbrecht, and I'm an open source (web) developer at heart and always try to up my game. Obviously, I'm also into gaming 🎮.