Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 129C5200B2D for ; Thu, 26 May 2016 19:11:15 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 11581160A18; Thu, 26 May 2016 17:11:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5DEDB160A2C for ; Thu, 26 May 2016 19:11:14 +0200 (CEST) Received: (qmail 54721 invoked by uid 500); 26 May 2016 17:11:13 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 54575 invoked by uid 99); 26 May 2016 17:11:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 May 2016 17:11:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 09B072C1F5C for ; Thu, 26 May 2016 17:11:13 +0000 (UTC) Date: Thu, 26 May 2016 17:11:13 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CAMEL-9984) RabbitConsumer.stop() doesn't stop underlying AutorecoveringConnection obtained from supplied ConnectionFactory MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 26 May 2016 17:11:15 -0000 [ https://issues.apache.org/jira/browse/CAMEL-9984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15302472#comment-15302472 ] ASF GitHub Bot commented on CAMEL-9984: --------------------------------------- Github user asfgit closed the pull request at: https://github.com/apache/camel/pull/996 > 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 > Assignee: Claus Ibsen > 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)