rabbitmq 接続の再試行を設定することは可能ですか? 可能であれば、それを行う方法は?
現在、アプリケーションから AMQP (RabbitMQ) に接続しています。rabbitmq がダウンしている場合、AmqpConnectionException がスローされ、接続を再確立するために 10 回再試行します。
15:50:41.533 [SimpleAsyncTaskExecutor-173] WARN o.s.a.r.l.SimpleMessageListenerContainer - **Consumer raised exception,** processing can restart if the connection factory supports it.
**Exception summary**: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
15:50:41.533 [SimpleAsyncTaskExecutor-173] INFO o.s.a.r.l.SimpleMessageListenerContainer - Restarting Consumer: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
15:50:42.565 [SimpleAsyncTaskExecutor-172] WARN o.s.a.r.l.SimpleMessageListenerContainer - Consumer raised exception, processing can restart if the connection factory supports it.
**Exception summary**: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
15:50:42.565 [SimpleAsyncTaskExecutor-172] INFO o.s.a.r.l.SimpleMessageListenerContainer - Restarting Consumer: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
15:50:43.567 [SimpleAsyncTaskExecutor-17] WARN o.s.a.r.l.SimpleMessageListenerContainer - Consumer raised exception, processing can restart if the connection factory supports it.
**Exception summary**: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
15:50:43.567 [SimpleAsyncTaskExecutor-17] INFO o.s.a.r.l.SimpleMessageListenerContainer - Restarting Consumer: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
15:50:44.581 [SimpleAsyncTaskExecutor-181] WARN o.s.a.r.l.SimpleMessageListenerContainer - Consumer raised exception, processing can restart if the connection factory supports it.
**Exception summary:** org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
15:50:44.581 [SimpleAsyncTaskExecutor-181] INFO o.s.a.r.l.SimpleMessageListenerContainer - Restarting Consumer: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
15:50:45.589 [SimpleAsyncTaskExecutor-180] WARN o.s.a.r.l.SimpleMessageListenerContainer - Consumer raised exception, processing can restart if the connection factory supports it.
**Exception summary**: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
15:50:45.589 [SimpleAsyncTaskExecutor-180] INFO o.s.a.r.l.SimpleMessageListenerContainer - Restarting Consumer: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
15:50:47.606 [SimpleAsyncTaskExecutor-179] WARN o.s.a.r.l.SimpleMessageListenerContainer - Consumer raised exception, processing can restart if the connection factory supports it.
**Exception summary**: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
15:50:47.606 [SimpleAsyncTaskExecutor-179] INFO o.s.a.r.l.SimpleMessageListenerContainer - Restarting Consumer: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
15:50:48.616 [SimpleAsyncTaskExecutor-178] WARN o.s.a.r.l.SimpleMessageListenerContainer - Consumer raised exception, processing can restart if the connection factory supports it.
**Exception summary**: org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused: connect
15:50:48.616 [http-nio-8443-exec-4] ERROR u.c.o.s.v.messaging.config.Sender - Excception has happened connecting to RabbitMQ
15:50:48.626 [SimpleAsyncTaskExecutor-178] INFO o.s.a.r.l.SimpleMessageListenerContainer - Restarting Consumer: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0
この再試行回数を 3 回に減らしてから終了する方法。
CachingConnectionFactory を使用して rabbitmq サーバーに接続しています。
public CachingConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setHost(env.getProperty("rabbitmq.host"));
connectionFactory.setPort(Integer.parseInt(env
.getProperty("rabbitmq.port")));
connectionFactory.setUsername(env.getProperty("rabbitmq.user"));
connectionFactory.setPassword(env.getProperty("rabbitmq.pass"));
return connectionFactory;
}