Sudarsana Kasireddy
Sudarsana Kasireddy

Reputation: 950

Bad messages handling with jms:message-driven-channel-adapter

I see one issue today.I have few messages dropped in a queue and one message is throwing error in service activator. the errorred message keep on trying again and again without other messages are processing from a queue. Is there any way I can set in below config to send error msg to end of queue messages. (ex if queue depth is 1000, error msg will be at 1000 pos)

 <jms:message-driven-channel-adapter id="exch" destination="requestQueue"   channel="jmsInChannel" 
                            transaction-manager="txManager" acknowledge="auto" concurrent-consumers="3"/>
<int:service-activator input-channel="jmsInChannel" ref="messageService"/>

Pls advice.

thanks Gary..Unfortunately we can't change any MQ configuration.

I have tried as follows and going to add service activator for errorRetryChannel.

<int:service-activator input-channel="jmsInChannel" ref="messageService">
         <int:request-handler-advice-chain>
            <int:retry-advice max-attempts="4" recovery-channel="errorRetryChannel">
                <int:exponential-back-off initial="1000" multiplier="5.0" maximum="60000" />
            </int:retry-advice>
    </int:request-handler-advice-chain>
    </int:service-activator>

Upvotes: 1

Views: 769

Answers (1)

Gary Russell
Gary Russell

Reputation: 174494

Typically, you would configure the broker to dump "poison" messages to a dead letter queue after some number of attempts.

If you can't do that, you can add a retry advice to your service activator together with a recoverer that can log and otherwise dispose of the bad message.

A custom recoverer could requeue the message at the tail of the queue but you will probably want to trash irrecoverable messages.

Upvotes: 1

Related Questions