Search code examples
rabbitmqrabbitmq-exchange

How to keep only the last object in a RabbitMQ exchange?


I have a RabbitMQ exchange where I put quotes that change several times per second.

When a new message is sent to the exchange, I would like undelivered messages to be dropped and only the last one to be sent.

Is this possible?

I’m doing this in F# but an example in any language would be appreciated.


Solution

  • Just configure the queue to have a max-length of 1. When the queue gets a new message, it will delete any older messages that are waiting in the queue.