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

Jörg Gonschior edited comment on CAMEL-15874 at 12/1/20, 3:35 PM:
------------------------------------------------------------------

Working with Philipp at the same project.

Tested both, but it ends up in multiple connections. The desired scenario of 
only one connection using multiple channels was not reached.

1.
{code:java}
autoDetectConnectionFactory: true
# connection-factory: cachedConnectionFactory  #inactive
{code}
{code:java}
pom.xml does not contain: spring-boot-starter-amqp
{code}
{code:java}
above Configuration class is not present
{code}
Result:

Instead of one connection 2 are added. Both connections are created from the 
<from uri expression.

 
||Name||username||...||
|{{10.131.65.XXX:60427}}
 {{~?~}}|{{rabbit-admin}}| |
|{{10.131.65.XXX:60425}}
 {{~?~}}|{{rabbit-admin}}| |
|...| | |

(ASCII art from Rabbit console)

 

2.
{code:java}
autoDetectConnectionFactory: false
connection-factory: cachedConnectionFactory  #active
{code}
{code:java}
pom.xml contains: spring-boot-starter-amqp
{code}
{code:java}
above Configuration class is present
{code}
Result:

Instead of one connection 3 are added. 2 connections with the name "?" are 
created from the <from uri expression. The third one comes from the dependency 
spring-boot-starter-amqp. This dependency is needed to be able to use the class 
org.springframework.amqp.rabbit.connection.CachingConnectionFactory in the 
config class.

Adding this we have to configure the rabbitMQ connection for Spring 
additionally using the properties: 
{code:java}
spring:
  rabbitmq:
    host: my-simulation-server
    port: 5672
    username: rabbit-admin
    password: xxx

{code}
||Name||username||...||
|{{10.131.65.XXX:60420}}
 {{~rabbitConnectionFactory#3b57dba4:0~}}|{{rabbit-admin}}| |
|{{10.131.65.XXX:60427}}
 {{~?~}}|{{rabbit-admin}}| |
|{{10.131.65.XXX:60425}}
 {{~?~}}|{{rabbit-admin}}| |
|...| | |

(ASCII art from Rabbit console)

 

 


was (Author: jgonschior):
Working with Philipp at the same project.

Tested both, but it ends up in multiple connections. The desired scenario of 
only one connection using multiple channels was not reached.

1.

 
{code:java}
autoDetectConnectionFactory: true
# connection-factory: cachedConnectionFactory  #inactive
{code}
 
{code:java}
pom.xml does not contain: spring-boot-starter-amqp
{code}
{code:java}
above Configuration class is not present
{code}
Result:

Instead of one connection 2 are added. Both connections are created from the 
<from uri expression.

 
||Name||username||...||
|{{10.131.65.XXX:60427}}
{{~?~}}|{{rabbit-admin}}| |
|{{10.131.65.XXX:60425}}
{{~?~}}|{{rabbit-admin}}| |
|...| | |

(ASCII art from Rabbit console)

 

2.
{code:java}
autoDetectConnectionFactory: false
connection-factory: cachedConnectionFactory  #active
{code}
{code:java}
pom.xml contains: spring-boot-starter-amqp
{code}
{code:java}
above Configuration class is present
{code}
Result:

Instead of one connection 3 are added. 2 connections with the name "?" are 
created from the <from uri expression. The third one comes from the dependency 
spring-boot-starter-amqp. This dependency is needed to be able to use the class 
org.springframework.amqp.rabbit.connection.CachingConnectionFactory in the 
config class.

Adding this we have to configure the rabbitMQ connection for Spring 
additionally using the properties: 
{code:java}
spring:
  rabbitmq:
    host: my-simulation-server
    port: 5672
    username: rabbit-admin
    password: xxx

{code}
||Name||username||...||
|{{10.131.65.XXX:60420}}
{{~rabbitConnectionFactory#3b57dba4:0~}}|{{rabbit-admin}}| |
|{{10.131.65.XXX:60427}}
{{~?~}}|{{rabbit-admin}}| |
|{{10.131.65.XXX:60425}}
{{~?~}}|{{rabbit-admin}}| |
|...| | |

(ASCII art from Rabbit console)

 

 

> Every endpoint using RabbitMQ creates a new connection instead of using only 
> one connection
> -------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-15874
>                 URL: https://issues.apache.org/jira/browse/CAMEL-15874
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-rabbitmq
>    Affects Versions: 3.4.4
>         Environment: OS Client: Linux 18.04
> OS Server: Linux 18.04
> Java: OpenJDK 11
> Camel: 3.4.4
> SpringBoot: 2.2.0
>            Reporter: Philipp
>            Priority: Major
>         Attachments: 2020-11-20 16_56_05-RabbitMQ Management.png, 2020-11-20 
> 16_57_16-RabbitMQ Management.png
>
>
> Consuming AMQP messages from RabbitMQ like the following results in multiple 
> physical connections being set up and used. Instead of using one single 
> connection and multiple channels per connection, as RabbitMQ 
> [suggests|https://www.rabbitmq.com/channels.html].
> {code:xml}
> <route id="fooRoute">
>     <!-- ... -->
>     <from uri="rabbitmq:?queue=foo.queue&amp;skipQueueBind=true"/>
>     <!-- ... -->
> </route>
> <route id="barRoute">
>     <!-- ... -->
>     <from uri="rabbitmq:?queue=bar.queue&amp;skipQueueBind=true"/>
>     <!-- ... -->
> </route>
> {code}
> Also using the following configuration ...
> {code:yaml}
> camel:
>   component:
>     rabbitmq:
>       autoDetectConnectionFactory: true
>       skip-exchange-declare: true
>       connection-factory: cachedConnectionFactory
> {code}
> {code:java}
> @Configuration
> public class Config{
>     private final 
> org.springframework.amqp.rabbit.connection.CachingConnectionFactory 
> rabbitConnectionFactory;
>     // ...
>     @Bean
>     com.rabbitmq.client.ConnectionFactory cachedConnectionFactory() {
>         return rabbitConnectionFactory.getRabbitConnectionFactory();
>     }
> }
> {code}
> ... results in the following log output:
> {code}
> 2020-11-20 16:35:13.854 DEBUG 17625 --- [           main] 
> o.a.c.c.rabbitmq.RabbitMQConsumer        : Using executor 
> org.apache.camel.util.concurrent.RejectableThreadPoolExecutor@4cd6f08b[Running,
>  pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 
> 0][rabbitmq://?queue=foo.queue&skipQueueBind=true]
> 2020-11-20 16:35:13.881 DEBUG 17625 --- [           main] 
> o.a.c.c.rabbitmq.RabbitMQConsumer        : Created connection: 
> amqp://[email protected]:5672/
> 2020-11-20 16:35:13.892 DEBUG 17625 --- [           main] 
> o.a.c.component.rabbitmq.RabbitConsumer  : Created channel: 
> AMQChannel(amqp://[email protected]:5672/,1)
> 2020-11-20 16:35:13.903  INFO 17625 --- [           main] 
> o.a.c.i.e.InternalRouteStartupManager    : Route: foo_distributorRoute 
> started and consuming from: rabbitmq://
> ...
> 2020-11-20 16:35:13.905 DEBUG 17625 --- [           main] 
> o.a.c.c.rabbitmq.RabbitMQConsumer        : Using executor 
> org.apache.camel.util.concurrent.RejectableThreadPoolExecutor@58835bba[Running,
>  pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 
> 0][rabbitmq://?queue=bar.queue&skipQueueBind=true]
> 2020-11-20 16:35:13.914 DEBUG 17625 --- [           main] 
> o.a.c.c.rabbitmq.RabbitMQConsumer        : Created connection: 
> amqp://[email protected]:5672/
> 2020-11-20 16:35:13.918 DEBUG 17625 --- [           main] 
> o.a.c.component.rabbitmq.RabbitConsumer  : Created channel: 
> AMQChannel(amqp://[email protected]:5672/,1)
> 2020-11-20 16:35:13.925  INFO 17625 --- [           main] 
> o.a.c.i.e.InternalRouteStartupManager    : Route: bar_distributorRoute 
> started and consuming from: rabbitmq://
> {code}
> See the attached screenshots from the RabbitMQ management dashboard.



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

Reply via email to