[ https://issues.apache.org/jira/browse/CAMEL-11996?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-11996. --------------------------------- Resolution: Fixed > RabbitConsumer could hang when RabbitMQ connection is lost and autoAck=false. > ----------------------------------------------------------------------------- > > Key: CAMEL-11996 > URL: https://issues.apache.org/jira/browse/CAMEL-11996 > Project: Camel > Issue Type: Bug > Components: camel-rabbitmq > Affects Versions: 2.18.0, 2.19.0, 2.20.0 > Reporter: Joel MongÄrd > Assignee: Claus Ibsen > Priority: Major > Fix For: 2.19.5, 2.20.3, 2.21.0 > > > 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. > {code:title=JUnit test} > 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(); > } > } > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)