MessageTTLAndDeadMessageQueue.java How to set up a queue for dead letter queues

In solace-samples-java-jcsmp MessageTTLAndDeadMessageQueue.java,
How can I specify a dead letter queue when creating a queue? In the sample code, I didn’t see a direct association between the dead letter queue and the queue containing TTL messages. What should I do?

Hi there, I’m Solly AI, I generate responses to your questions using the power of the Solace Agent Mesh:

Please remember that AI technology can make mistakes so ensure that you read our Disclaimer.

AI Generated responses are a work in progress, your help in evaluating my response would be awesome! If my response makes sense, please mark it as a solution or give a :+1:. If my response doesn’t make sense for your topic, please react to it with a :shaking_face:.

Looking at the documentation, I can explain how dead letter queues (DMQs) work with messages in Solace:

For a message to be moved to a DMQ instead of being discarded, several conditions must be met:

  1. The DMQ must exist on the same event broker service
  2. The queue must be configured to respect TTL values (if using TTL-based discarding)
  3. The maximum redeliver count must be configured (if using redelivery-based discarding)
  4. Most importantly - the publishing client must designate messages as DMQ-eligible

For the specific MessageTTLAndDeadMessageQueue.java sample, to make messages eligible for DMQ handling, you need to:

  1. Set DMQ eligibility on the message using:
message.setDMQEligible(true)
  1. Configure the destination queue with:
  • A DMQ name
  • Respect TTL enabled
  • Maximum TTL value (optional)
  • Maximum redelivery count (optional)

The documentation shows that DMQ eligibility is set as a message flag, where a value of true enables a published message to be DMQ-eligible.

Relevant documentation links:

I recommend checking the full MessageTTLAndDeadMessageQueue sample code on the Solace Developer Hub for a complete example.

Hi @trifolium.wang ,

A small continuation of the response from Solly-AI chat :slight_smile:
You will need to setup a new standard queue which will act as the DMQ seperately and associate it with the main queue as in the screenshot below.
The DMQ name specification is under advanced settings on a queue and can be accessed by the Show Advanced Settings button on the top right inside the queue settings.

The other properties like message expiry and TTL are available under the same advanced settings as you scroll down.

Hope this answers your questions.

Regards
Hari