Creating a message queue service

A long-term solution to handle event data had to be both flexible and scalable

By , Senior PHP developer

A long-term solution to handle event data had to be both flexible and scalable

The Challenge

As part of our move to a headless services architecture, we needed our WordPress CMS to push data into a content API. An initial solution, built upon existing technology and developed within WordPress, had several issues. We needed a long-term solution.

The Solution

To achieve a flexible, scalable outcome, we decided to build a separate message queue service.

Built using API Platform, the message queue service accepts a message that describes an event that has occurred. Specifically, in the case of WordPress, that event is the creation, updating or deletion of a piece of content.

The message queue service then adds this message to the queue, for which we used AWS’s Simple Queue Service. Using a queue designed for this purpose gave us somewhere to store the message and meant it would only be handled once (and be able to be tried again, should it fail).

A worker picks up a message from the queue and passes on the event to that event’s dedicated handler. The handler then lets other services know what they need to do in response to that event. In our initial use case, the worker lets WordPress know that it should push the required data into the content API.

The Impact

Since its launch, the message queue service has proven to be extremely reliable, with a success rate of more than 99.7%. By building it with API platform outside of WordPress, it has also allowed other services to send their own events to be handled with minimal work required by the developer.

Work with us

Fancy joining our growing team?

Get in touch

Throw us a line