[
https://issues.apache.org/jira/browse/CAMEL-14405?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Arnaud Chotard updated CAMEL-14405:
-----------------------------------
Description:
The Camel RabbitMQ endpoint has a connectionFactory property allowing you to
use an existing RabbitMQ connection factory.
{{{color:#172b4d}from("rabbitmq://server:5672?connectionFactory=#brokerConnectionFactory&...");{color}}}
{{{color:#172b4d}ConnectionFactory brokerConnectionFactory = new
com.rabbitmq.client.ConnectionFactory();{color}}}
{{{color:#172b4d} brokerConnectionFactory.setHost(hostname);{color}}}
{{{color:#172b4d} brokerConnectionFactory.setPort(port);{color}}}
{{{color:#172b4d} brokerConnectionFactory.setVirtualHost(virtualHost);{color}}}
{{{color:#172b4d} brokerConnectionFactory.setUsername(username);{color}}}
{{{color:#172b4d} brokerConnectionFactory.setPassword(password);{color}}}
{{{color:#172b4d}
brokerConnectionFactory.setAutomaticRecoveryEnabled(true);{color}}}
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 :
{{{color:#172b4d}from("rabbitmq://server:5672?connectionFactory=#brokerConnectionFactory&automaticRecoveryEnabled=...");{color}}}
1/ If camelEndpoint.automaticRecoveryEnabled = false and
connectionFactory.automaticRecoveryEnabled = false => The connection and the
channel are manually recreated by Camel RabbitMQ on the other hand the doStart
() is not invoked by the start () and the consumption of messages via
channel.basicConsume is never reset.
2/ If camelEndpoint.automaticRecoveryEnabled = true and
connectionFactory.automaticRecoveryEnabled = false => 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.
3/ If camelEndpoint.automaticRecoveryEnabled = false and
connectionFactory.automaticRecoveryEnabled = true => 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.
4/ If camelEndpoint.automaticRecoveryEnabled = true and
connectionFactory.automaticRecoveryEnabled = true => It works.
The cause of 1 seems to come from the doStart() method which is not called if
the consumer is already started :
{{{color:#172b4d}@Override protected void doStart() throws Exception {{color}}}
{{{color:#172b4d} if (channel == null) { {color}}}
{{{color:#172b4d} throw new IOException("The RabbitMQ channel is not
open"); {color}}}
{{{color:#172b4d} }{color}}}
{{{color:#172b4d} tag =
channel.basicConsume(consumer.getEndpoint().getQueue(),
consumer.getEndpoint().isAutoAck(), "", false,
consumer.getEndpoint().isExclusiveConsumer(), null, this); {color}}}
{{{color:#172b4d}}}}
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 :
{{{{private boolean isAutomaticRecoveryEnabled() {}}}}
{{ return this.endpoint.getAutomaticRecoveryEnabled() != null}}
{{{color:#172b4d} && this.endpoint.getAutomaticRecoveryEnabled();{color}}}
{{ {color:#172b4d}{{}}}{color}}}
was:
The Camel RabbitMQ endpoint has a connectionFactory property allowing you to
use an existing RabbitMQ connection factory.
{{{color:#172b4d}from("rabbitmq://server:5672?connectionFactory=#brokerConnectionFactory&...");{color}}}
{{{color:#172b4d}ConnectionFactory brokerConnectionFactory = new
com.rabbitmq.client.ConnectionFactory();{color}}}
{{{color:#172b4d} brokerConnectionFactory.setHost(hostname);{color}}}
{{{color:#172b4d} brokerConnectionFactory.setPort(port);{color}}}
{{{color:#172b4d} brokerConnectionFactory.setVirtualHost(virtualHost);{color}}}
{{{color:#172b4d} brokerConnectionFactory.setUsername(username);{color}}}
{{{color:#172b4d} brokerConnectionFactory.setPassword(password);{color}}}
{{{color:#172b4d}
brokerConnectionFactory.setAutomaticRecoveryEnabled(true);{color}}}
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 :
{{{color:#172b4d}from("rabbitmq://server:5672?connectionFactory=#brokerConnectionFactory&automaticRecoveryEnabled=...");{color}}}
1/ If camelEndpoint.automaticRecoveryEnabled = false and
connectionFactory.automaticRecoveryEnabled = false => The connection and the
channel are manually recreated by Camel RabbitMQ on the other hand the doStart
() is not invoked by the start () and the consumption of messages via
channel.basicConsume is never reset.
2/ If camelEndpoint.automaticRecoveryEnabled = true and
connectionFactory.automaticRecoveryEnabled = false => 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.
3/ If camelEndpoint.automaticRecoveryEnabled = false and
connectionFactory.automaticRecoveryEnabled = true => 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.
4/ If camelEndpoint.automaticRecoveryEnabled = true and
connectionFactory.automaticRecoveryEnabled = true => It works.
The cause of 1 seems to come from the doStart() method which is not called if
the consumer is already started :
{{{color:#172b4d}@Override protected void doStart() throws Exception {{color}}}
{{{color:#172b4d} if (channel == null) { {color}}}
{{{color:#172b4d} throw new IOException("The RabbitMQ channel is not
open"); {color}}}
{{{color:#172b4d} }{color}}}
{{{color:#172b4d} tag =
channel.basicConsume(consumer.getEndpoint().getQueue(),
consumer.getEndpoint().isAutoAck(), "", false,
consumer.getEndpoint().isExclusiveConsumer(), null, this); {color}}}
{{{color:#172b4d}}{color}}}
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 :
{{private boolean isAutomaticRecoveryEnabled() {}}
{color:#172b4d}{{ return this.endpoint.getAutomaticRecoveryEnabled() != null
}}{color}
{color:#172b4d}{{ && this.endpoint.getAutomaticRecoveryEnabled();
}}{color}
{color:#172b4d}{{}}}{color}
> Problem when recovering RabbitMQ connections when using a connectionFactory
> and the automaticRecovery 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
>
> The Camel RabbitMQ endpoint has a connectionFactory property allowing you to
> use an existing RabbitMQ connection factory.
> {{{color:#172b4d}from("rabbitmq://server:5672?connectionFactory=#brokerConnectionFactory&...");{color}}}
> {{{color:#172b4d}ConnectionFactory brokerConnectionFactory = new
> com.rabbitmq.client.ConnectionFactory();{color}}}
> {{{color:#172b4d} brokerConnectionFactory.setHost(hostname);{color}}}
> {{{color:#172b4d} brokerConnectionFactory.setPort(port);{color}}}
> {{{color:#172b4d}
> brokerConnectionFactory.setVirtualHost(virtualHost);{color}}}
> {{{color:#172b4d} brokerConnectionFactory.setUsername(username);{color}}}
> {{{color:#172b4d} brokerConnectionFactory.setPassword(password);{color}}}
> {{{color:#172b4d}
> brokerConnectionFactory.setAutomaticRecoveryEnabled(true);{color}}}
> 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 :
> {{{color:#172b4d}from("rabbitmq://server:5672?connectionFactory=#brokerConnectionFactory&automaticRecoveryEnabled=...");{color}}}
> 1/ If camelEndpoint.automaticRecoveryEnabled = false and
> connectionFactory.automaticRecoveryEnabled = false => The connection and the
> channel are manually recreated by Camel RabbitMQ on the other hand the
> doStart () is not invoked by the start () and the consumption of messages via
> channel.basicConsume is never reset.
> 2/ If camelEndpoint.automaticRecoveryEnabled = true and
> connectionFactory.automaticRecoveryEnabled = false => 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.
> 3/ If camelEndpoint.automaticRecoveryEnabled = false and
> connectionFactory.automaticRecoveryEnabled = true => 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.
> 4/ If camelEndpoint.automaticRecoveryEnabled = true and
> connectionFactory.automaticRecoveryEnabled = true => It works.
> The cause of 1 seems to come from the doStart() method which is not called if
> the consumer is already started :
> {{{color:#172b4d}@Override protected void doStart() throws Exception
> {{color}}}
> {{{color:#172b4d} if (channel == null) { {color}}}
> {{{color:#172b4d} throw new IOException("The RabbitMQ channel is not
> open"); {color}}}
> {{{color:#172b4d} }{color}}}
> {{{color:#172b4d} tag =
> channel.basicConsume(consumer.getEndpoint().getQueue(),
> consumer.getEndpoint().isAutoAck(), "", false,
> consumer.getEndpoint().isExclusiveConsumer(), null, this); {color}}}
> {{{color:#172b4d}}}}
>
> 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 :
>
> {{{{private boolean isAutomaticRecoveryEnabled() {}}}}
> {{ return this.endpoint.getAutomaticRecoveryEnabled() != null}}
> {{{color:#172b4d} &&
> this.endpoint.getAutomaticRecoveryEnabled();{color}}}
> {{ {color:#172b4d}{{}}}{color}}}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)