org.springframework.amqp.rabbit.retry.RejectAndDontRequeueRecoverer - Retries exhausted for message
org.springframework.amqp.rabbit.listener.ListenerExecutionFailedException: Listener threw exception
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.wrapToListenerExecutionFailedExceptionIfNeeded(AbstractMessageListenerContainer.java:758)
After this I have to restart the container to receive messages again. The code I am using is given below:
@Bean
SimpleMessageListenerContainer container(
ConnectionFactory connectionFactory, Object listenerAdapter) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setQueueNames(queueName);
container.setMessageListener(listenerAdapter);
container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
container.setAdviceChain(workMessagesAdviceChain()); // for retry logic
return container;
}
private Advice[] workMessagesAdviceChain() {
return new Advice[] { workMessagesRetryInterceptor() };
}
@Bean
public RetryOperationsInterceptor workMessagesRetryInterceptor() {
return RetryInterceptorBuilder.stateless().retryOperations(retryTemplate(3)).recoverer(new RejectAndDontRequeueRecoverer()).build();
}
@Bean
public Queue queue() {
return new Queue(queueName);
}
@Bean
public Queue deadLetterQueue() {
Map<String, Object> arguments = new HashMap<String, Object>();
arguments.put("x-dead-letter-exchange", exchangeName);
arguments.put("x-message-ttl", 300000);
return new Queue("deadLetterQueue", true, false, false, arguments);
}
@Bean
DirectExchange exchange() {
return new DirectExchange(exchangeName, true, false);
}
@Bean
Binding binding() {
return BindingBuilder.bind(queue()).to(exchange()).with(queueName);
}
@Bean
Object listenerAdapter() {
return new MessageReceiver();
}
public class MessageReceiver implements ChannelAwareMessageListener {
@Override
public void onMessage(org.springframework.amqp.core.Message message, Channel channel) throws Exception {
//Some business logic
if(msgHandled)
throw new RuntimeException("Message cannot be handled right now " + message);
else
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
}
}
What am I doing wrong in the configuration? Why is the container stopping? When I run rabbitmqctl list_queues I cn see the deadLetterQueue but messages are not getting routed to it. Please help!!!
Thanks,
Shuchi
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.