How To Set Number Of Retries For A Message?

Posted by Admin on 31-Mar-2011 11:51

Hi there,

I am fairly new to using SonicMQ, and wish to know more about

- Where to set some default settings in terms of message delivery? ie number of retries to send a message before sending to the Dead Letter Queue?

- How to override this number. At What Level can this be done? ie (This might be more of a generic JMS question, but I am asking in relation to the Sonic API)

                    - Connection?

                    - Session?

                    - Would the producer , when sending this message, override this setting? ie 'For this message retry X times. etc etc

                    - The Queue itself? ie For this queue, all messages will be retried to sent to consumers X times. etc etc

                    - At all of the above levels?

The background is that I have some test code, which , in the success case, simply consumes from a JMS queue, and persists the information to a database. I am specifically testing the case of a database failure, where the message is consumed from a Queue, and attempted to be persisted to a database, but cannot because the database is down. (I re-enact this using a Camel Interceptor.)

The sending of the message is abstracted away, by the fact that I am using Camel to do much of the work. Previously, I was using ActiveMQ as the MOM, and the test worked successfully. The ActiveMQ MOM tried to deliver the message it's default of 6 times, before keeping the message in the Dead Letter Queue. My test code checks that the message ends up in the dead letter queue.

When I try and configure and use SonicMQ as the MOM, the success case works fine. However, the test of enacting the database to be down does not work. The message seems to be re delivered upto 560 or so times, and then ends up in the same queue, NOT the dead letter queue. (My test fails as it checks the existence of the message in the 'SonicMQ.deadMessage' queue).

Any ideas on how I can configure SonicMQ in regards of the above?

(Further information is that I have set all of this up using Spring Configuration. I set up the queue on the Sonic Management Console, just using the default settings. I am using

progress.message.jclient.QueueConnectionFactory as the Connection Factory, and also, a

org.springframework.jms.connection.JmsTransactionManager as the txManager.)

Thanks For Any Help.

All Replies

Posted by csemeniu on 31-Mar-2011 14:06

You can set the max delivery count on the connection factory used by the consumer:

progress.message.jclient.QueueConnectionFactory.setMaxDeliveryCount (Integer value).

The default is no limit. In order for the message to end up on the DeadMessageQueue after exceeding delivery retries, the producer has to set the message property JMS_SonicMQ_preserveUndelivered to true before sending the message, otherwise the message will be dropped.

The following has more info about setting max delivery count and about the DeadMessageQueue:

http://documentation.progress.com/output/Sonic/8.0.1/Docs8.0/books/mq_application_program.pdf

Posted by Admin on 01-Apr-2011 04:31

Thank you for this swift reply!. Setting the maxDeliveryCount() on the connection factory, (QueueConnectionFactory) did infact work.

However, I am wondering about how to set the 'JMS_SonicMQ_preserveUndelivered' boolean property, as a default.

The reference guide gives examples of how it is set, by setting on the message itself...

ie

// Set the msg to be preserved in the Dead Message Queue.

msg

setBooleanProperty(“JMS_SonicMQ_preserveUndelivered”, true);

However, Is there any way of setting this as a default setting in SonicMQ, ie across all messages, or across this connectionFactory etc etc? Many Thanks For Help.

Posted by csemeniu on 04-Apr-2011 15:06

There isn't a way to set preserveUndelivered as the default. You could implement redelivery limit in the receiver by checking the message property JMSXDeliveryCount and sending the message to another destination when the limit is exceeded.

This thread is closed