Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.18.0, 2.19.0, 2.20.0
-
None
-
Unknown
Description
When the connection is lost to a RabbitMQ server and later restored there is the possibility that the RabbitConsumer hangs. The only way around this that I found is to restart my application.
I have experienced this problem in my testing environment running camel 2.18.3 where my RabbitMQ installation is not stable causing every consumer thread to hang on lock.acquire() .
The problem has been introduced in version 2.18.0 commit 7ee0977c9f5c327a95122f5b80202dc5dd872e40
A possible fix could be to include the statement if (!channel.isOpen()) return; in the try-finally block below it.
package org.apache.camel.component.rabbitmq; import org.junit.Test; import org.mockito.Mockito; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; public class RabbitConsumerTest { private RabbitMQConsumer consumer = Mockito.mock(RabbitMQConsumer.class); private RabbitMQEndpoint endpoint = Mockito.mock(RabbitMQEndpoint.class); private Connection conn = Mockito.mock(Connection.class); private Channel channel = Mockito.mock(Channel.class); @Test(timeout=5000) public void testHandleDelivery_ShouldNotHangForeverIfChanelWasClosed() throws Exception { Mockito.when(consumer.getEndpoint()).thenReturn(endpoint); Mockito.when(consumer.getConnection()).thenReturn(conn); Mockito.when(conn.createChannel()).thenReturn(channel); Mockito.when(channel.isOpen()).thenReturn(false).thenReturn(true); RabbitConsumer rabbitConsumer = new RabbitConsumer(consumer); rabbitConsumer.handleDelivery(null, null, null, null); rabbitConsumer.handleDelivery(null, null, null, null); rabbitConsumer.stop(); } }
Attachments
Issue Links
- relates to
-
CAMEL-11480 camel-rabbitmq - autorecovery creates additional channels
- Closed