[rabbitmq-discuss] Retry Message for 3 times with 10 seconds interval - in Consumer

Srinath Sridharan -X (srinatsr - ZENSAR TECHNOLOGIES INC at Cisco) srinatsr at cisco.com
Tue May 20 20:29:57 BST 2014


Thanks  do you have xml version of the following?

I need to set message id before publishing the message?  How to do this?

Regards …•
Srinath

From: rabbitmq-discuss [mailto:rabbitmq-discuss-bounces at lists.rabbitmq.com] On Behalf Of Gary Russell
Sent: Tuesday, May 20, 2014 12:24 PM
To: Discussions about RabbitMQ
Subject: Re: [rabbitmq-discuss] Retry Message for 3 times with 10 seconds interval - in Consumer

@Bean
public MethodInterceptor retryAdvice() {
     FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
     backOffPolicy.setBackOffPeriod(10000);;
     return RetryInterceptorBuilder.stateful()
          .backOffPolicy(backOffPolicy)
          .maxAttempts(3)
          .recoverer(new RejectAndDontRequeueRecoverer())
          .build();
}

Add it to the adviceChain property of the SimpleMessageListenerContainer.

Note: stateful retry requires the message to have a message id; use a stateless advice otherwise.

After the retries are exhausted, the message will be rejected (and dropped or sent to a Dead Letter Exchange of so configured).


On Tue, May 20, 2014 at 3:09 PM, Srinath Sridharan -X (srinatsr - ZENSAR TECHNOLOGIES INC at Cisco) <srinatsr at cisco.com<mailto:srinatsr at cisco.com>> wrote:

Hello,

I am consuming the messages using the listener as follows,  I need to retry processing three times if any exceptions occurred.

<bean
        class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer">
        <property name="connectionFactory" ref="connectionFactory" />
        <property name="queueNames">
            <array>
                <value>validateRequestQueue</value>
            </array>
        </property>
        <property name="messageListener">
            <bean
                class="org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter">
                <property name="delegate" ref="retryConsumer" />
            </bean>
        </property>
        <!-- <property name="acknowledgeMode" value="NONE" /> -->
    </bean>


public class RetryConsumer implements ChannelAwareMessageListener {

       /**
       * Callback for processing a received Rabbit message.
       * @param message the received AMQP message
       * @param channel the underlying Rabbit Channel
       * @throws Exception
        */
       @Override
       public void onMessage(Message message, Channel channel) throws Exception {

             System.out.println("Received Message :: "+new String(message.getBody()));
             if(true){
             throw new RuntimeException("Error");
             }

       }

Regards …•
Srinath

From: Srinath Sridharan -X (srinatsr - ZENSAR TECHNOLOGIES INC at Cisco)
Sent: Monday, May 19, 2014 10:47 AM
To: rabbitmq-discuss at lists.rabbitmq.com<mailto:rabbitmq-discuss at lists.rabbitmq.com>
Subject: Retry Message for 3 times with 10 seconds interval - in Consumer



Retry unacknowledged RabbitMQ message in 10 second interval

And Retry 3 times using Spring framework in java .



Please need help on this

Regards …•
Srinath


_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss at lists.rabbitmq.com<mailto:rabbitmq-discuss at lists.rabbitmq.com>
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140520/8504395b/attachment.html>


More information about the rabbitmq-discuss mailing list