PeculiarOrbit
PeculiarOrbit

Reputation: 1

Prioritize Newest Messages in RabbitMQ

I am working on an application where real-time sensor readings are passed via RabbitMQ queues to an uploader which pushes the readings to a central server. In this particular application, the most recent readings are the most valuable. This means that I would prefer that the uploader processes the most recent reading first, moving backward in time through any backlog which has accumulated.

To achieve this effect, I was hoping that RabbitMQ would have a "stack" construct where consumers are fed the most recent messages first. However, I couldn't find anything like this in the RabbitMQ documentation.

One solution I came up with was to create a "real-time" queue and a "backlog" queue. Messages in the real-time queue would have a short TTL, and thus would be moved to the backlog if they were not processed quickly. This solves the problem of pushing the most recent reading first, but the backlog would still be processed in the wrong order.

Any suggestions on how I could achieve newest-message-first processing in RabbitMQ?

Upvotes: 0

Views: 109

Answers (1)

pinepain
pinepain

Reputation: 12859

What about using priority queues?

RabbitMQ has priority queue implementation in the core as of version 3.5.0.

Also, pay attention to Interaction with other features section in referenced manual page.

Upvotes: 2

Related Questions