我正在尝试重新发送消息(如果处理消息失败),在特定时间段(初始延迟)后定期(重新发送延迟)并且如果在我希望的一定数量的重新传递尝试后仍然无法处理该消息将它发送到deadletter队列但是无法实现相同的
你能帮帮我吗。消费
public class Consumer {
@RabbitListener(queues="com.infy.priority-queue")
public void receivedMessage(String message) throws IOException {
System.out.println(message);//message format - message with priorty(6)/5/4..
if(message.endsWith("6"))
throw new NullPointerException();
}
我的配置如下:
public abstract class AMQPConfig {
@Autowired
private ConnectionFactory connectionFactory;
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory()
{
factory = new SimpleRabbitListenerContainerFactory();
factory.setConnectionFactory(this.connectionFactory);
factory.setPrefetchCount(1);
return factory;
}
@Bean
public Queue salesQueue() {
return QueueBuilder.durable("priority-queue")
.withArgument("x-max-priority", 10)
.withArgument("redeliveryPolicy.initialRedeliveryDelay", 6000L)
.withArgument("redeliveryPolicy.redeliveryDelay", 3000L)
.withArgument("redeliveryPolicy.maximumRedeliveries", 3)
.withArgument("redeliveryPolicy.maximumRedeliveryDelay",5000L)
.withArgument("x-dead-letter-exchange", "")
.withArgument("x-dead-letter-routing-key", salesErrorRoutingKey)
.build();
}
@Bean
public Queue deadLetterQueue() {
return QueueBuilder.durable(deadLetterQueue).build();
}
}