【问题标题】:All Camel routes stop when activemq is not working当 activemq 不工作时,所有骆驼路线都会停止
【发布时间】:2015-04-04 14:30:31
【问题描述】:

我正在使用具有两条路线的基于 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>

【问题讨论】:

  • 你有什么例外吗?
  • 不,我没有看到任何异常。
  • 我建议将 org.apache.camel 设置为 DEBUG 并查看它记录的内容

标签: apache-camel activemq


【解决方案1】:

使用asyncStartListener 选项并将其设置为true 以启动ActiveMQ 异步,这将允许其他路由和Camel 启动。在文档中查看更多信息:http://camel.apache.org/jms

<from uri="activemq:queue:testMQ?asyncStartListener=true"/>

【讨论】:

  • 我对 asyncStartListener 的文档有疑问。这似乎意味着一段时间后,如果您尝试连接的端点仍未启动,您将不得不通过 JMX 接口手动重新启动路由。此外,查看文档,似乎没有设置连接超时间隔的方法。如果发生这种情况,有没有办法控制路由在放弃和记录异常之前尝试连接多长时间?
猜你喜欢
  • 2017-05-31
  • 1970-01-01
  • 2013-01-21
  • 2018-01-30
  • 2018-09-05
  • 2016-01-13
  • 2015-05-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多