user1159791
user1159791

Reputation: 505

RabbitMQ queue order management

I'm currently implementing rabbitMQ for a tracking system with multiple front producers writing on the same queue.

Basically i have two types of messages that are sent in the queue, as the tracking workflow has two steps : impression/click => lead/sale. It is very simple : The user clicks a banner, then performs an action on the website that he was redirected to. This action can take a few seconds to a few days to be done. I need to consume the lead or sale AFTER the according impresison or click.

The problem is that i need to consume messages in a chronological order. While everything should be good if all producers send messages in the queue at the same speed (ie, the messages should order properly in a FIFO way) i will have issues when one of the producer writes (for some reason) slower in the queue.

For example, if my lead action occurs one second after the click action, and the click producers stalls for a couple seconds, i'll consume the lead before the click and my tracking system won't work.

I'd like to know how to set an order for a queue according to a header that's attached to the message. All my servers are synchronized and their clocks have <1ns difference, so i'd like to order my queue according to this information, but i can't find anywhere in the doc a way to setup the queue order or consumption order.

Thanks for your help.

Upvotes: 3

Views: 13502

Answers (2)

pinepain
pinepain

Reputation: 12859

AMQP queues are FIFO queue. Under high numbers simultaneous message been published there might be some ambiguity which message come first, so you may expect that message one and message two might not be in same order in queue as they happened in real world. It's a price you have pay for HA and speed. If you want to know more about it you can ask a question on IRC rabbitmq channel.

Upvotes: 10

Nikitin Mikhail
Nikitin Mikhail

Reputation: 3019

I think the queue means the queue, i.e. first in - first out. Mabe you can sort them during the consumption? I mean you take, for example, 10 messages from the queue, parse them, and put them to your own queue or list in the proper order.

Upvotes: 0

Related Questions