title: Apache Camel JMS : How to use JNDI connection to publish or Subscribe to a Queue using java DSL?
body: <p>I am trying to connect to JMS queue from JBoss EAP 7.0  using camel. I am using Java DSL not Spring. How can I get the JNDI entries and create a connection to listen or dispatch a message?<br>
  Below are the code segment I am using to connect to <code>ActiveMQ</code> in general!</p>
  
  <pre><code>CamelContext context = new DefaultCamelContext();
  context.addComponent("activemq", ActiveMQComponent.activeMQComponent("tcp://localhost:61616"));
  context.addRoutes(new RouteBuilder() {
      public void configure() {
          from("direct:writeQueue").to("activemq:queue:FOO");
      }
  });
  context.start();
  Thread.sleep(2000);
  ProducerTemplate producer = context.createProducerTemplate();
  producer.sendBody("activemq:queue:FOO", "Test Message");
  </code></pre>
  
  <p>I have tried adding code like below :</p>
  
  <pre><code>CamelContext context = null;
  @Resource(mappedName = "java:/jboss/exported/jms/queue/TestQ")
  private ConnectionFactory connectionFactory;
  public void testJMS() throws Exception {
  
      context = new DefaultCamelContext();
      JmsComponent component = new JmsComponent();
      component.setConnectionFactory(connectionFactory);
      context.addComponent("jms", component);
      /*
      Routing Section
      */
  }
  </code></pre>
  
  <p>But this code is giving me error like :<code>connectionFactory must not be null</code></p>