You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Rastislav Papp (Jira)" <ji...@apache.org> on 2021/07/19 10:59:00 UTC

[jira] [Commented] (CAMEL-16707) camel-rabbitmq connection leak on error during 'declare'

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

Rastislav Papp commented on CAMEL-16707:
----------------------------------------

[~davsclaus], the new camel-rabbitmq property {{recoverFromDeclareException}} has a default value of true (so as not to change the previous behavior). It is declared in the endpoint and in the component as:
{code:java}
@Metadata(label = "consumer")
private boolean recoverFromDeclareException = true;{code}

> camel-rabbitmq connection leak on error during 'declare'
> --------------------------------------------------------
>
>                 Key: CAMEL-16707
>                 URL: https://issues.apache.org/jira/browse/CAMEL-16707
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-rabbitmq
>    Affects Versions: 3.6.0
>            Reporter: Rastislav Papp
>            Priority: Minor
>             Fix For: 3.7.5, 3.11.0
>
>
> camel-rabbitmq component causes a connection leak when there is an error during declaration of exchanges/queues (e.g. when an exchange with the same name but different type already exists).
> Problem lies in {{org.apache.camel.component.rabbitmq.RabbitConsumer}}:
> {code:java}
>     RabbitConsumer(RabbitMQConsumer consumer) {
>         // super(channel);
>         this.consumer = consumer;
>         try {
>             Connection conn = consumer.getConnection();
>             this.channel = openChannel(conn);
>         } catch (IOException | TimeoutException e) {
>             LOG.warn("Unable to open channel for RabbitMQConsumer. Continuing and will try again", e);
>         }
>     }
>     //...
>     private Channel openChannel(Connection conn) throws IOException {
>         Channel channel = //... channel gets created
>         //...
>         if (consumer.getEndpoint().isDeclare()) {
>             consumer.getEndpoint().declareExchangeAndQueue(channel);
>         }
>         return channel;
>     }
> {code}
> if {{declareExchangeAndQueue}} gets called, and if it throws an exception (e.g. because the exchange is already declared with different configuration) the exception is caught and consumed in the constructor, and the channel is never closed. I think the exception should be propagated in this case, because it is not recoverable (or at least there should be an option for this). It would also cause the app startup to fail, which would be a good thing in this case.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)