title: RabbitMQ and Camel with Multiple connection factories
body: <p>I am trying to implement routing solution in which i need to read messages from one queue of rabbit mq and put message on different rabbit mq/different queue.</p>
  
  <p>I was able to make read and write separately from queues but it is not working together.</p>
  
  <p>Here is camel configuration file :</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
      &lt;beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:rabbit="http://www.springframework.org/schema/rabbit"
             xmlns:context="http://www.springframework.org/schema/context"
             xsi:schemaLocation="
             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
             http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
             http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
             http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd"&gt;
  
          &lt;context:annotation-config/&gt;
          &lt;context:component-scan base-package="amqp.spring.camel.component"/&gt;
  
          &lt;camelContext xmlns="http://camel.apache.org/schema/spring"&gt;
  
              &lt;jmxAgent id="agent" createConnector="false" disabled="true" /&gt;
              &lt;template id="wfcTemplate" /&gt;
              &lt;template id="routerTemplate" /&gt;
  
              &lt;route&gt;
                  &lt;from uri="spring-amqp:exchange1:queue1:ABCD?type=topic&amp;amp;autodelete=false&amp;amp;durable=true" /&gt;
                  &lt;log  message="Message available on a RabbitMQ Queue : ${body}" /&gt;
                  &lt;to uri="spring-amqp:exchange2:queue2:EFGH?type=topic&amp;amp;autodelete=false&amp;amp;durable=true" /&gt;
              &lt;/route&gt;
          &lt;/camelContext&gt;
  
  
          &lt;rabbit:connection-factory id="producerConnectionFactory" connection-factory="producerConnectionFactory" /&gt;
          &lt;rabbit:template id="routerTemplate" connection-factory="producerConnectionFactory" message-converter="messageConverter" exchange="exchange2" /&gt;
          &lt;rabbit:admin connection-factory="producerConnectionFactory" /&gt;
          &lt;bean id="producerConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory"&gt;
              &lt;property name="host" value="10.0.10.100"/&gt;
              &lt;property name="port" value="5672"/&gt;
              &lt;property name="username" value="shailesh"/&gt;
              &lt;property name="password" value="shailesh"/&gt;
              &lt;property name="virtualHost" value="vh1"/&gt;
          &lt;/bean&gt;
  
          &lt;rabbit:connection-factory id="consumerConnectionFactory" connection-factory="consumerConnectionFactory"/&gt;
          &lt;rabbit:template id="wfcTemplate" connection-factory="consumerConnectionFactory" message-converter="messageConverter" exchange="exchange1" /&gt;
          &lt;rabbit:admin connection-factory="consumerConnectionFactory"/&gt;
          &lt;bean id="consumerConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory"&gt;
              &lt;property name="host" value="10.0.10.101"/&gt;
              &lt;property name="port" value="5672"/&gt;
              &lt;property name="username" value="shailesh"/&gt;
              &lt;property name="password" value="shailesh"/&gt;
              &lt;property name="virtualHost" value="vh2"/&gt;
          &lt;/bean&gt;
  
          &lt;!-- converters --&gt;
          &lt;bean id="jsonMessageConverter" class="amqp.spring.converter.XStreamConverter"/&gt;
          &lt;bean id="textMessageConverter" class="amqp.spring.converter.StringConverter"/&gt;
          &lt;bean id="messageConverter" class="amqp.spring.converter.ContentTypeConverterFactory"&gt;
              &lt;property name="converters"&gt;
                  &lt;map&gt;
                      &lt;entry key="application/json" value-ref="jsonMessageConverter"/&gt;
                      &lt;entry key="application/xml" value-ref="textMessageConverter"/&gt;
                  &lt;/map&gt;
              &lt;/property&gt;
              &lt;property name="fallbackConverter" ref="textMessageConverter"/&gt;
          &lt;/bean&gt;
  
      &lt;/beans&gt;
  </code></pre>
  
  <p>There error I am getting is as follows :</p>
  
  <pre><code>    [pache.camel.spring.Main.main()] SpringCamelContext             INFO  Total 1 routes, of which 1 is started.
      [pache.camel.spring.Main.main()] SpringCamelContext             INFO  Apache Camel 2.10.3 (CamelContext: camel-1) started in 0.589 seconds
      [PConsumer.SpringAMQPExecutor-1] route1                         INFO  Message available on a RabbitMQ Queue : Hello, world! Fri Feb 08 14:14:33 CST 2013
      [l-1) thread #0 - amqp-producer] SpringAMQPProducer             ERROR Could not deliver message via AMQP
      java.lang.NullPointerException
          at amqp.spring.camel.component.SpringAMQPProducer$AMQPProducerTask.run(SpringAMQPProducer.java:150)[camel-spring-amqp-1.4.jar:]
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_11]
          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_11]
          at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_11]
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)[:1.7.0_11]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)[:1.7.0_11]
          at java.lang.Thread.run(Thread.java:722)[:1.7.0_11]
  </code></pre>