Spring 具有多个连接工厂的RabbitMQ和Camel

Spring 具有多个连接工厂的RabbitMQ和Camel,spring,rabbitmq,Spring,Rabbitmq,我正在尝试实现路由解决方案,其中我需要从rabbit mq的一个队列读取消息,并将消息放在不同的rabbit mq/不同的队列上 我能够使读和写与队列分开,但不能一起工作 下面是camel配置文件: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w

我正在尝试实现路由解决方案,其中我需要从rabbit mq的一个队列读取消息,并将消息放在不同的rabbit mq/不同的队列上

我能够使读和写与队列分开,但不能一起工作

下面是camel配置文件:

    <?xml version="1.0" encoding="UTF-8"?>

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

        <context:annotation-config/>
        <context:component-scan base-package="amqp.spring.camel.component"/>

        <camelContext xmlns="http://camel.apache.org/schema/spring">

            <jmxAgent id="agent" createConnector="false" disabled="true" />
            <template id="wfcTemplate" />
            <template id="routerTemplate" />

            <route>
                <from uri="spring-amqp:exchange1:queue1:ABCD?type=topic&amp;autodelete=false&amp;durable=true" />
                <log  message="Message available on a RabbitMQ Queue : ${body}" />
                <to uri="spring-amqp:exchange2:queue2:EFGH?type=topic&amp;autodelete=false&amp;durable=true" />
            </route>
        </camelContext>


        <rabbit:connection-factory id="producerConnectionFactory" connection-factory="producerConnectionFactory" />
        <rabbit:template id="routerTemplate" connection-factory="producerConnectionFactory" message-converter="messageConverter" exchange="exchange2" />
        <rabbit:admin connection-factory="producerConnectionFactory" />
        <bean id="producerConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
            <property name="host" value="10.0.10.100"/>
            <property name="port" value="5672"/>
            <property name="username" value="shailesh"/>
            <property name="password" value="shailesh"/>
            <property name="virtualHost" value="vh1"/>
        </bean>

        <rabbit:connection-factory id="consumerConnectionFactory" connection-factory="consumerConnectionFactory"/>
        <rabbit:template id="wfcTemplate" connection-factory="consumerConnectionFactory" message-converter="messageConverter" exchange="exchange1" />
        <rabbit:admin connection-factory="consumerConnectionFactory"/>
        <bean id="consumerConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
            <property name="host" value="10.0.10.101"/>
            <property name="port" value="5672"/>
            <property name="username" value="shailesh"/>
            <property name="password" value="shailesh"/>
            <property name="virtualHost" value="vh2"/>
        </bean>

        <!-- converters -->
        <bean id="jsonMessageConverter" class="amqp.spring.converter.XStreamConverter"/>
        <bean id="textMessageConverter" class="amqp.spring.converter.StringConverter"/>
        <bean id="messageConverter" class="amqp.spring.converter.ContentTypeConverterFactory">
            <property name="converters">
                <map>
                    <entry key="application/json" value-ref="jsonMessageConverter"/>
                    <entry key="application/xml" value-ref="textMessageConverter"/>
                </map>
            </property>
            <property name="fallbackConverter" ref="textMessageConverter"/>
        </bean>

    </beans>
    [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]