0

I have a couple of queues where certain information is queued. Let us say I have "success" and "failed" queues in which Server side component has continuously written some data to these queues for clients.

Clients read this data and display it on a UI for end users. Now, I have a situation to purge any message in these queues older than 30 days. Clients would then only be able to see only 30 days of information at any point of time.

I have searched a lot and could see some command line options to purge whole queue but could not find a relevant suggestion.

Any help in the right direction is appreciated. Thanks

techspider
  • 3,370
  • 13
  • 37
  • 61

1 Answers1

2

I don't think this is possible; looks like you're trying to use RabbitMq as data storage instead of message server.

The only way to understand if a message is "older" than 30, is to process the message, and by doing this you are removing the messagge from the queue. Best thing to do here is to process the messages and store them in a long term storage; then you can implement a deletion policy to eliminate the older elements.

If you really want to go down this path, RabbitMQ implements TTL at queue level or message level; take a look at this: https://www.rabbitmq.com/ttl.html

[As discussed in comments]

To keep the message in the queue you can try to use a NACK instead of ACK as confirmation; this way RabbitMQ will consider the message undelivered and it will try to deliver it again and again. Remember to create a durable queue (https://www.rabbitmq.com/confirms.html).

You can also check this answer: Rabbitmq Ack or Nack, leaving messages on the queue

Community
  • 1
  • 1
Luca Ghersi
  • 3,261
  • 18
  • 32
  • Client UI is supposed to read the messages in these queues whenever they want. Is there a flag or option to keep the message in the queue while reading it from the queue? I want to delete the message only if it exceeds expiration policy but should be available for multiple-read requests from client – techspider Mar 15 '16 at 15:29
  • Luca is right - you're looking for data storage, like a database, not RabbitMQ. when a message is published, it should be consumed once and then you can do whatever you need in other systems, like store it in a database so it can be accessed multiple times. – Derick Bailey Mar 15 '16 at 21:31
  • @techspider I just added a brief section about ack and nack on my answer, mabye it will be useful to you. – Luca Ghersi Mar 16 '16 at 06:47
  • Thanks @LucaGhersi; I understand your logic to solve my problem though it is not conventional. – techspider Mar 17 '16 at 13:44