Search code examples
databasejmspersistencedata-recovery

JMS auto persistance and auto recovery


I'm trying to solve the next task:

  1. I have 1 output queue and 1 input queue and database.
  2. If output queue is not available, I need to persist all input messages to DB.
  3. As soon as output queue being available, input queue (or broker) should start send all messages from DB and, at the same time, delete these messages from DB. All should be done automatically, not manually.

Are any message brokers (ActiveMQ, RabbitMQ) have "out of the box" solution or not?


Solution

  • I don't think any of the messaging providers provide out of the box support that you are asking for. You need to write an application to do that job. The application can be very simple that uses global transactions to coordinate putting messages to queue and removing from database.

    If your business logic allows, I would suggest you to look at the possibility of using persistent messages when putting to input queue. This way you can avoid persisting messages to a database when output queue is not available. When the output queue becomes available, your application can pull messages from input queue, process and put to output queue.