Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-15874

Every endpoint using RabbitMQ creates a new connection instead of using only one connection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Information Provided
    • 3.4.4
    • 3.x
    • camel-rabbitmq
    • None
    • OS Client: Linux 18.04
      OS Server: Linux 18.04
      Java: OpenJDK 11

      Camel: 3.4.4
      SpringBoot: 2.2.0

    • Unknown

    Description

      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.

      <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>
      

      Also using the following configuration ...

      camel: 
        component: 
          rabbitmq: 
            autoDetectConnectionFactory: true
            skip-exchange-declare: true
            connection-factory: cachedConnectionFactory
      
      @Configuration
      public class Config{
      
          private final org.springframework.amqp.rabbit.connection.CachingConnectionFactory rabbitConnectionFactory;
      
          // ...
      
          @Bean
          com.rabbitmq.client.ConnectionFactory cachedConnectionFactory() {
              return rabbitConnectionFactory.getRabbitConnectionFactory();
          }
      }
      

      ... results in the following log output:

      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://ebb-client@10.131.67.XXX:5672/
      2020-11-20 16:35:13.892 DEBUG 17625 --- [           main] o.a.c.component.rabbitmq.RabbitConsumer  : Created channel: AMQChannel(amqp://ebb-client@10.131.67.XXX: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://ebb-client@10.131.67.XXX:5672/
      2020-11-20 16:35:13.918 DEBUG 17625 --- [           main] o.a.c.component.rabbitmq.RabbitConsumer  : Created channel: AMQChannel(amqp://ebb-client@10.131.67.XXX: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://
      

      See the attached screenshots from the RabbitMQ management dashboard.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              pmontesano Philipp
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: