You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2021/03/22 18:03:00 UTC

[jira] [Resolved] (CAMEL-14405) Problem when recovering RabbitMQ connections when using a connectionFactory and the automaticRecoveryEnabled option

     [ https://issues.apache.org/jira/browse/CAMEL-14405?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-14405.
---------------------------------
    Resolution: Information Provided

Use camel-spring-rabbitmq instead

> Problem when recovering RabbitMQ connections when using a connectionFactory and the automaticRecoveryEnabled option
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-14405
>                 URL: https://issues.apache.org/jira/browse/CAMEL-14405
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-rabbitmq
>    Affects Versions: 2.24.3
>            Reporter: Arnaud Chotard
>            Priority: Major
>             Fix For: 3.x
>
>
> The Camel RabbitMQ endpoint has a connectionFactory property allowing you to use an existing RabbitMQ connection factory.
> {code:java}
> from("rabbitmq://server:5672?connectionFactory=#brokerConnectionFactory&...");
> ConnectionFactory brokerConnectionFactory = new com.rabbitmq.client.ConnectionFactory();
>   brokerConnectionFactory.setHost(hostname);
>   brokerConnectionFactory.setPort(port);
>   brokerConnectionFactory.setVirtualHost(virtualHost);
>   brokerConnectionFactory.setUsername(username);
>   brokerConnectionFactory.setPassword(password);
>   brokerConnectionFactory.setAutomaticRecoveryEnabled(true);
> {code}
> The documentation states "When this option is set, all connection options (connectionTimeout, requestedChannelMax…) set on URI are not used".
> We observed problems during the recovery of connections to the broker when using the automaticRecoveryEnabled option which is present at the connectionFactory level and at the camelEndpoint level :
> {code:java}
> from("rabbitmq://server:5672?connectionFactory=#brokerConnectionFactory&automaticRecoveryEnabled=...");
> {code}
> *1/* If camelEndpoint.automaticRecoveryEnabled = false and connectionFactory.automaticRecoveryEnabled = false => {color:#de350b}The connection and the channel are manually recreated by Camel RabbitMQ. On the other hand the doStart () is not invoked by the start () an{color}{color:#de350b}d the consumption of messages via channel.basicConsume is never reset. Messages are no longer consumed.{color}
> *2/* If camelEndpoint.automaticRecoveryEnabled = true and connectionFactory.automaticRecoveryEnabled = false => {color:#de350b}Endless attempt to reconnect: Unable to obtain a RabbitMQ channel. Will try again. Caused by: Waiting for channel to re-open. Camel waits for RabbitMQ client to reset connection indefinitely{color}{color:#de350b}.{color} {color:#de350b}Messages are no longer consumed.{color}
> *3/* If camelEndpoint.automaticRecoveryEnabled = false and connectionFactory.automaticRecoveryEnabled = true => {color:#de350b}Conflict in reopening channels by Camel Endpoint and by RabbitMQ client. Unknown delivery tag when using basickAck in doHandleDelivery and ShutdownSignalException at the initiative of the application{color}{color:#de350b}. Messages are no longer consumed.{color}
> *4/* If camelEndpoint.automaticRecoveryEnabled = true and connectionFactory.automaticRecoveryEnabled = true => {color:#00875a}It works{color}.
> The cause of 1 seems to come from the doStart() method which is not called if the consumer is already started :
> {code:java}
> @Override 
> protected void doStart() throws Exception {
>    if (channel == null) { 
>       throw new IOException("The RabbitMQ channel is not open"); 
>    }
>    tag = channel.basicConsume(consumer.getEndpoint().getQueue(), consumer.getEndpoint().isAutoAck(), "", false, consumer.getEndpoint().isExclusiveConsumer(), null, this); 
> }
> {code}
> The cause of 2 and 3 seems to come from the isAutomaticRecoveryEnabled() methods of RabbitConsumer and RabbitMQConsumer classes which tests the value of the property automaticRecoveryEnabled only on the camelEndpoint and not on the connectionFactory :
> {code:java}
> private boolean isAutomaticRecoveryEnabled() {}}
>     return this.endpoint.getAutomaticRecoveryEnabled() != null
>         && this.endpoint.getAutomaticRecoveryEnabled();
> }
> {code}



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