camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-11996) RabbitConsumer could hang when RabbitMQ connection is lost and autoAck=false.
Date Tue, 07 Nov 2017 15:46:00 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-11996?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16242219#comment-16242219
] 

Claus Ibsen commented on CAMEL-11996:
-------------------------------------

You are welcome to provide a fix as github PR if you want to try doing that
http://camel.apache.org/contributing

> 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
>             Fix For: 2.19.5, 2.20.1, 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
(v6.4.14#64029)

Mime
View raw message