Why (and how) you should use Message Queues in Magento 2

Josh Carter
6 min readJun 10, 2022

And so it began..

With the release of Magento 2.3.0 we were treated to something new baked into the core that in my opinion Magento had been lacking for some time. Message Queue functionality. Sure there were third party options out there, you could’ve written your own implementation, your own RabbitMQ adapters etc. But we’ve all tried to convince clients and customers alike to spend time/money on nice to have improvements that they probably will never really appreciate.

So since 2.3 we don’t have to worry about writing the whole mechanism ourselves, it’s done for us in the core framework, along with its own group of obligatory Magento 2 XML config files (more on them later).

Why (and when) should we use Message Queues?

In a similar way to how I very rarely write new traditional Block classes anymore in Magento 2, in favour of ViewModels. The same can be said about cron jobs, before message queuing in Magento 2 the cron was a less-than-perfect, but viable, solution for running tasks in the background, the ones you didn’t want the end user to have to wait for — now we have message queues for that.

This isn’t me saying that cron jobs are redundant, more that we can just use them how they’re supposed to be…

--

--