Grails JMS Plugin and Redelivery Policy

18 / Mar / 2010 by Vivek Krishna 1 comments

On a project, we needed to configure the redelivery mechanism for the JMS queue. That is, a poisonous message was to be sent to a Dead Letter Queue if a set number of attempts failed, so that the other messages in the queue could be processed. The JMS Plugin version used was 0.5

Merely configuring ActiveMQ for setting up a Dead Letter Queue like :

<policyEntry queue=”>” memoryLimit=”5mb”>
<deadLetterStrategy>
<individualDeadLetterStrategy queuePrefix=”DLQ.” useQueueForQueueMessages=”true” />
</deadLetterStrategy>
</policyEntry>

And injecting the bean redeliveryPolicy into jmsConnectionFactory bean inside resources.groovy like this:

jmsRedeliveryPolicy(org.apache.activemq.RedeliveryPolicy){
        maximumRedeliveries = 3
        initialRedeliveryDelay = 500L
        backOffMultiplier = 2
        useExponentialBackOff = true
    }
    jmsConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) {
        brokerURL = 'tcp://localhost:61616'
        redeliveryPolicy = jmsRedeliveryPolicy
    }

did not do the trick. When an exception was thrown in the listener method in any service exposed to JMS, the message was staying in the queue and halting processing of subsequent messages.

A change in the configuration of the “standard” container was required and this was done in Config.groovy as :

jms {
    containers {
        standard {
            sessionTransacted = true
        }
    }
}

This did the trick and the redelivery policy and dead letter queue mechanism started working the way we wanted it to.

Hope it helps

Vivek

FOUND THIS USEFUL? SHARE IT

comments (1 “Grails JMS Plugin and Redelivery Policy”)

  1. apartmani zagreb

    Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something. I think that you could do with some pics to drive the message home a little bit, but other than that, this is excellent blog. An excellent read. I’ll definitely be back.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *