camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-9984) RabbitConsumer.stop() doesn't stop underlying AutorecoveringConnection obtained from supplied ConnectionFactory
Date Tue, 24 May 2016 08:28:13 GMT

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

ASF GitHub Bot commented on CAMEL-9984:
---------------------------------------

GitHub user daknin opened a pull request:

    https://github.com/apache/camel/pull/996

    CAMEL-9984: Rabbit MQ connection is not closed when channel has been closed by server.

    This fixes closing Rabbit MQ connections when the server has already closed the channel
/ connection. I created an issue at https://issues.apache.org/jira/browse/CAMEL-9984 with
full details.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/daknin/camel CAMEL-9984

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/camel/pull/996.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #996
    
----
commit 09613cb4c3be053195e1c9f68f3a485d0003d24d
Author: Darrell King <darrell.king@hermes-europe.co.uk>
Date:   2016-05-24T08:18:53Z

    CAMEL-9984: Rabbit MQ connection is not closed when channel has been closed by server.

----


> RabbitConsumer.stop() doesn't stop underlying AutorecoveringConnection obtained from
supplied ConnectionFactory
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-9984
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9984
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-rabbitmq
>    Affects Versions: 2.17.1
>            Reporter: Darrell King
>            Priority: Minor
>             Fix For: 2.17.2, 2.18.0
>
>
> If I have a ConnectionFactory defined as:
> {code:borderStyle=solid}
> ConnectionFactory connectionFactory = new ConnectionFactory();
> connectionFactory.setAutomaticRecoveryEnabled(true);
> connectionFactory.setUsername(username);
> connectionFactory.setPassword(password);
> {code}
> And a Camel route defined like:
> {code:borderStyle=solid}
> rabbitmq://localhost:5672/MyExchange?connectionFactory=#connectionFactory&exchangeType=direct&queue=MyQueue&routingKey=MyRoutingKey
> {code}
> Performing these steps:
> * Start my application and it connects to Rabbit and consumes messages
> * Shutdown the RabbbitMQ server
> * Shutdown my Camel application
> The application doesn't stop fully because the automatic recovery mechanism has background
threads running. It carries on indefinately logging messages like:
> {code:borderStyle=solid}
> 	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
> 	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
> 	at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:350)
> 	at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:37)
> 	at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.recoverConnection(AutorecoveringConnection.java:476)
> 	at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.beginAutomaticRecovery(AutorecoveringConnection.java:444)
> 	at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.access$000(AutorecoveringConnection.java:53)
> 	at com.rabbitmq.client.impl.recovery.AutorecoveringConnection$1.shutdownCompleted(AutorecoveringConnection.java:383)
> 	at com.rabbitmq.client.impl.ShutdownNotifierComponent.notifyListeners(ShutdownNotifierComponent.java:75)
> 	at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:578)
> {code}
> Looking at org.apache.camel.component.rabbitmq.RabbitConsumer.stop()
> {code:borderStyle=solid}
>     public void stop() throws IOException, TimeoutException {
>         stopping = true;
>         if (channel == null) {
>             return;
>         }
>         channel.basicCancel(tag);
>         try {
>             channel.close();
>         } catch (TimeoutException e) {
>             log.error("Timeout occured");
>             throw e;
>         }
>     }
> {code}
> The calls to channel.basicCancel(tag) and channel.close() both throw com.rabbitmq.client.AlreadyClosedException
when the server has closed the connection which stops the automatic recovery thread from being
halted. Checking whether the channel is open before the calls to channel.basicCancel(tag)
and channel.close() seems to fix the issue.
> {code:borderStyle=solid}
>     public void stop() throws IOException, TimeoutException {
>         stopping = true;
>         if (channel == null) {
>             return;
>         }
>         if (tag != null && isChannelOpen()) {
>             channel.basicCancel(tag);
>         }
>         try {
>             if (isChannelOpen()) {
>                 channel.close();
>             }
>         } catch (TimeoutException e) {
>             log.error("Timeout occured");
>             throw e;
>         }
>     }
> {code}
> I'll submit a PR later



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message