title: Camel use same JMS Component in many routes
body: <p>I'm trying to configure 3 Camel Routes to use the same JMS Component.</p>
  
  <p>The problem is when I "have" to use the same component in these differents routes.
  When I do that, sometimes an error is showed up informing wasn't possible to connect to ActiveMQ is showed up.
  Is this happening because concurrency?
  If yes, I would like to know if is there possible configure this component at once and use it without this concurrency.</p>
  
  <p>When I define the componenets with different name, it works.
  E.g: amq1, amq2 and amq3.</p>
  
  <p>I'm using:</p>
  
  <ul>
  <li>Apache Camel: <strong>2.21</strong></li>
  <li>ActiveMQ Artemis: <strong>1.5.6</strong></li>
  <li>Springboot: <strong>v1.5.16.RELEASE</strong></li>
  </ul>
  
  <p>The code:
  Method to create the JMS Component:</p>
  
  <pre><code>  public JmsComponent createComponent() {
      private ActiveMQJMSConnectionFactory connection;
      connection = new ActiveMQJMSConnectionFactory(host, user, password);
      connection.setMinLargeMessageSize(10000000);
  
      return JmsComponent.jmsComponent(connection);
    }
  </code></pre>
  
  <p>Adding the Component to route:</p>
  
  <p>Route 1:</p>
  
  <pre><code>@Component
  public class Route1 extends RouteBuilder {
  
    @Override
    public void configure() throws Exception {
  
      if (!getContext().getComponentNames().contains("amq")) {
        getContext().addComponent("amq", createComponent());
      }
      from("amq:" + queue)
        .routeId("Route1")
        .to("mock:result");
    }
  }
  </code></pre>
  
  <p>Route 2:</p>
  
  <pre><code>@Component
  public class Route2 extends RouteBuilder {
  
    @Override
    public void configure() throws Exception {
  
      if (!getContext().getComponentNames().contains("amq")) {
        getContext().addComponent("amq", createComponent());
      }
      from("amq:" + queue)
        .routeId("Route2")
        .to("mock:result");
    }
  }
  </code></pre>
  
  <p>Route 3:</p>
  
  <pre><code>@Component
  public class Route3 extends RouteBuilder {
  
    @Override
    public void configure() throws Exception {
  
      if (!getContext().getComponentNames().contains("amq")) {
        getContext().addComponent("amq", createComponent());
      }
  
      from("timer:Test?period=2s")
        .routeId("Route3")
        .setBody(simple("test"))
        .to("amq:" + queue);
    }
  }
  </code></pre>
  
  <p>AMQ Broker acceptor:</p>
  
  <pre><code>      &lt;acceptors&gt;
  
           &lt;acceptor name="artemis"&gt;tcp://0.0.0.0:61616?connectionTtl=60000;needClientAuth=true;supportAdvisory=false;anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300&lt;/acceptor&gt;
  
           &lt;acceptor name="amqp"&gt;tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;amqpCredits=1000;amqpLowCredits=300&lt;/acceptor&gt;
  
           &lt;acceptor name="stomp"&gt;tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true&lt;/acceptor&gt;
  
           &lt;acceptor name="hornetq"&gt;tcp://0.0.0.0:5445?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;protocols=HORNETQ,STOMP;useEpoll=true&lt;/acceptor&gt;
  
           &lt;acceptor name="mqtt"&gt;tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true&lt;/acceptor&gt;
  
        &lt;/acceptors&gt;
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>Error processing exchange. Exchange[ID-op20190003-01-valenet-18-wlgfm-1560467581146-0-2]. Caused by: [org.springframework.jms.UncategorizedJmsException - Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Failed to create session factory; nested exception is ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ119007: Cannot connect to server(s). Tried with all available servers.]]
  org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Failed to create session factory; nested exception is ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ119007: Cannot connect to server(s). Tried with all available servers.]
      at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
      at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
      at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:487)
      at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:526)
      at org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:440)
      at org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:394)
      at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:157)
      at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
      at org.apache.camel.component.direct.DirectBlockingProducer.process(DirectBlockingProducer.java:53)
      at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
      at org.apache.camel.component.direct.DirectBlockingProducer.process(DirectBlockingProducer.java:53)
      at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
      at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:197)
      at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:79)
      at java.util.TimerThread.mainLoop(Timer.java:555)
      at java.util.TimerThread.run(Timer.java:505)
  Caused by: javax.jms.JMSException: Failed to create session factory
      at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:757)
      at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:265)
      at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:260)
      at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180)
      at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474)
      ... 26 common frames omitted
  Caused by: org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException: AMQ119007: Cannot connect to server(s). Tried with all available servers.
      at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:784)
      at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:755)
  ... 30 common frames omitted
  </code></pre>