title: Apache Camel JMS Connection to QueueConnectionFactory using Spring
body: <p>I was looking through various examples for Apache Camel Jms connection and was trying to figure out if i can
  wire in a <code>QueueConnectionFactory</code> for a custom Jms provider to my JmsComponent?</p>
  
  <p>So i want to lookup the queue name through jndi
  but i have the custom <code>QueueConnectionFactory</code> to create the connection
  and then from that call <code>createQueueSession</code>.</p>
  
  <p>My sudo code is as follows:</p>
  
  <pre><code>&lt;bean id="customQueueConnectionFactory" class="QueueConnectionFactoryImpl"/&gt;
  
  &lt;bean id="authenticatedConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter"&gt;
    &lt;property name="targetConnectionFactory" ref="customQueueConnectionFactory"/&gt;
    &lt;property name="username" value="username"/&gt;
    &lt;property name="password" value="password"/&gt;
  &lt;/bean&gt;
  
  
  &lt;bean id="jms" class="org.apache.camel.component.jms.JmsComponent"&gt; 
    &lt;property name="connectionFactory" ref="authenticatedConnectionFactory"/&gt; 
  &lt;/bean&gt;
  </code></pre>
  
  <p>This is failing as its not the right way to wire in a QueueConnectionFactory.</p>
  
  <pre><code>QueueConnectionFactoryImpl.createConnection(Ljava/lang/String;Ljava/lang/String;)Ljavax/jms/Connection;
      at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.doCreateConnection(UserCredentialsConnectionFactoryAdapter.java:175)
      at org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter.createConnection(UserCredentialsConnectionFactoryAdapter.java:150)
      at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
      at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:405)
      at org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:373)
      at org.springframework.jms.listener.DefaultMessageListenerContainer.establishSharedConnection(DefaultMessageListenerContainer.java:767)
      at org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:280)
      at org.springframework.jms.listener.AbstractJmsListeningContainer.start(AbstractJmsListeningContainer.java:265)
      at org.springframework.jms.listener.DefaultMessageListenerContainer.start(DefaultMessageListenerContainer.java:568)
      at org.apache.camel.component.jms.JmsConsumer.startListenerContainer(JmsConsumer.java:105)
      at org.apache.camel.component.jms.JmsConsumer.prepareAndStartListenerContainer(JmsConsumer.java:171)
      at org.apache.camel.component.jms.JmsConsumer.doStart(JmsConsumer.java:155)
  </code></pre>
  
  <p>Any hints? I am using Spring version 3.2.4 &amp; Apache Camel version 2.12.2</p>