1

We want a rabbitmq message to be consumed by the queue after a certain delay that is in days for now but could in weeks or months in the future.

The exact scenario is:- we have a classified website where stock inserted by the user has to be deleted automatically after exactly 7 days. So, is it a good idea to publish rabbitmq message to delete the stock with a delay of 7 days. We want this to be deleted exactly after 7 days so nightly/hourly job to check stocks and delete them would not work.

I know its possible and read it here but Is using rabbitmq-scheduling correct for such scenarios? OR is there any other alternative to solve this?

Sahil Sharma
  • 3,847
  • 6
  • 48
  • 98
  • I think that a major issue with using RabbitMQ for this application is that you need the stock deleted guaranteed while RabbitMQ provides a best try type of approach in which if no one is there to take a message then the message is discarded. That would not seem to be appropriate for a classified website where guaranteed action on a specific time is required. – Richard Chambers Feb 13 '18 at 21:26
  • but we will keep a consumer running to consume messages – Sahil Sharma Feb 13 '18 at 21:32
  • 1
    It is possible, but it's bad design. Just like it is possible to build your house out of straw, you can force the message broker to do this. However, since the primary function of the broker is to connect producers with consumers, delays are not part of that purpose. I would recommend the use of a database. – theMayer Feb 13 '18 at 22:01
  • See https://stackoverflow.com/questions/48295196/samza-delay-processing-of-messages-until-timestamp/48387262#48387262 – theMayer Feb 13 '18 at 22:04
  • Possible duplicate of [Delayed message in RabbitMQ](https://stackoverflow.com/questions/4444208/delayed-message-in-rabbitmq) – theMayer Feb 13 '18 at 22:05
  • Don't do this. Use a real scheduling framework to publish a "delete" message after 7 days have elapsed. – NWard Feb 13 '18 at 22:28

0 Answers0