我有一个通过以下方式配置了RetryTemplate的RabbitTemplate:
@Bean
public RabbitTemplate myRabbitTemplate()
{
RabbitTemplate template = new RabbitTemplate(myConnectionFactory());
template.setChannelTransacted(true);
template.setMessageConverter(myMessageConverter());
template.setReplyAddress(MY_RESPONSE_PRIVATE_QUEUE);
template.setQueue(MY_RESPONSE_PRIVATE_QUEUE);
template.setMandatory(true);
template.setEncoding("UTF-8");
template.setExchange(MY_REQUEST_EXCHANGE);
template.setBeforePublishPostProcessors(new MyMessagePostProcessor());
RetryTemplate retryTemplate = new RetryTemplate();
ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
backOffPolicy.setInitialInterval(500);
backOffPolicy.setMultiplier(10.0);
backOffPolicy.setMaxInterval(10000);
retryTemplate.setBackOffPolicy(backOffPolicy);
template.setRetryTemplate(retryTemplate);
template.setAfterReceivePostProcessors(new DelegatingDecompressingPostProcessor());
return template;
}
使用TCPView和WireShark进行连接测试,我认为在其中一个连接剪切中,已发送的消息之一已被复制(我猜是通过RetryTemplate的配置)。
在整个项目中,还有其他连接失败和错误(ShutdownSignalException,TimeOut ...),并且我们从未检测到重复的消息。 在什么情况下会重新尝试发送邮件?
谢谢
编辑11/03/2019
现在,我有更多有关重复消息的信息。在发送消息的过程中(并且在接收到ACK之前),发生了连接错误:
06-03-2019 10:09:52.919|WARN |com.rabbitmq.client.impl.ForgivingExceptionHandler|120||AMQP Connection XXX.XX.XX.XX:XXXXX|An unexpected connection driver error occured (Exception message: Connection reset)
com.rabbitmq.client.ShutdownSignalException: connection error
at com.rabbitmq.client.impl.AMQConnection.startShutdown(AMQConnection.java:868)
at com.rabbitmq.client.impl.AMQConnection.shutdown(AMQConnection.java:858)
at com.rabbitmq.client.impl.AMQConnection.handleFailure(AMQConnection.java:681)
at com.rabbitmq.client.impl.AMQConnection.access$400(AMQConnection.java:47)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:582)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
服务器收到两条消息,它们具有相同的spring_listener_return_correlation但具有不同的spring_request_return_correlation:
spring_listener_return_correlation=0475d6f3-4859-418d-93fe-ed96fb28e733, spring_request_return_correlation=2926
spring_listener_return_correlation=0475d6f3-4859-418d-93fe-ed96fb28e733, spring_request_return_correlation=2927
“ RetryTemplate”的配置是否可能是重复发货的原因?
谢谢