当activemq不工作时,所有Camel路由都会停止

时间:2015-04-04 14:30:31

标签: apache-camel activemq

我使用的是基于xml的驼峰上下文,它有两条路由。 Route1从本地activeMQ中的队列读取,Route2由驼峰定时器组件启动,并且没有对activeMQ的引用。

启动activeMQ后,我启动了我的驼峰应用程序,两条路线都运行良好。但是,当activeMQ停止时,两条路线都会停止工作。

由于Route2与activeMQ没有任何关联,因此它不能继续工作吗?我尝试在两个骆驼环境中定义2条路线,但它没有解决问题。你能帮帮我吗?

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

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
          http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!-- The ActiveMQ connection factory with specification of the server URL -->
    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL" value="failover://tcp://localhost:61616" />
                <property name="userName" value="admin"/>
                <property name="password" value="admin"/>
            </bean>
        </property>
    </bean>

    <bean id="myApp" class="org.camel.poc.App"/>
    <bean id="testProcessor" class="org.camel.poc.TestProcessor"/>


  <!-- here is Camel configured with a number of routes -->
  <camelContext id="camel1" xmlns="http://camel.apache.org/schema/spring">

    <route id="3">
        <from uri="activemq:queue:testMQ"/>
        <!--process ref="myApp"/-->
        <to uri="activemq:queue:testMQDestination2"/>
    </route>

  </camelContext>

  <camelContext id="camel2" xmlns="http://camel.apache.org/schema/spring">
    <route id="2">
        <from uri="timer://foo?fixedRate=true&amp;period=5000"/>
        <process ref="testProcessor"/>
    </route>
</camelContext>
</beans>

1 个答案:

答案 0 :(得分:2)

使用asyncStartListener选项并将其设置为true以启动ActiveMQ异步,这将允许其他路由和Camel启动。请参阅文档中的详细信息:http://camel.apache.org/jms

<from uri="activemq:queue:testMQ?asyncStartListener=true"/>
相关问题