user1732364
user1732364

Reputation: 985

Amazon MQ Message Delivery and Persistence Configuration

I have a use case where the queue needs to be up 24/7 so redundancy is key thus multi AZ is required. Aside from that, I want to ensure the messages to the queue satisfy the following requirements but I've never configured AMQ or ActiveMQ before so I am a bit lost.

  1. Messages retain during queue reboot = Persistence mode
  2. Messages are able to be read by multiple consumers
  3. Messages do not immediately fall off the queue after first read (acknowledgement)
  4. Potentially configure the life span of a message to be available for a time window like 48 hours.

Any samples or guidance on the XML configurations to meet these requirements would be fantastic. I haven't found much online for items 2-4.

Upvotes: 0

Views: 1650

Answers (1)

Anton Goncharov
Anton Goncharov

Reputation: 403

ActiveMQ

ActiveMQ is a JMS-compliant message broker. Most of the requirements you listed are controlled by properties on a producer side.

I'm using Java snippets in the answers.

  1. MessageProducer producer = session.createProducer(session.createQueue(queueName)); producer.setDeliveryMode(DeliveryMode.PERSISTENT);

  2. Sending a message to several recipients is a "publisher-subscriber" pattern instead of "producer-consumer". Create a topic that is a target for multiple client subscriptions. Otherwise you'd like to have a queue per recipient. JMS Topic Example.

  3. Choose whatever mode is appropriate for you among these options: https://docs.oracle.com/cd/E19798-01/821-1841/bncfw/index.html. It's likely you require CLIENT_ACKNOWLEDGE and sending ack manually using acknowledge() method. Acknowledge mode is set on JMS session:

    Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);

  4. producer.setTimeToLive(ttl);

Amazon SQS (Simple Queue Service)

Amazon SQS also adheres to the JMS protocol, so the ActiveMQ API examples above for 1,3,4 are still valid for SQS, as SQSConnection class extends javax.jms.Connection. Please follow the Getting Started guide for more detailed steps.

  1. SQS provides guarantees regarding message persistence (https://aws.amazon.com/message-queue/features/);

  2. Pub/Sub pattern is available for Amazon MQ as well (https://aws.amazon.com/pub-sub-messaging/).

Upvotes: 1

Related Questions