2017-05-18 79 views
2

我很新的这个话题,需要一些解释...新手:ActiveMQ的骆驼

我们有一个正在运行的ActiveMQ-Server,它现在应该与Apache骆驼路由和处理增强。我们的整个配置是基于XML的。

我的第一种方法是在我们的activemq.xml文件末尾做一个普通的<import resource="camel.xml">,但这似乎是错误的路径。

这些都是当前transortConnectors:

<transportConnectors> 
    <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --> 
    <transportConnector name="openwire" uri="tcp://localdev:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> 
    <transportConnector name="amqp" uri="amqp://localdev:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> 
    <transportConnector name="stomp" uri="stomp://localdev:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> 
    <transportConnector name="mqtt" uri="mqtt://localdev:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> 
    <transportConnector name="ws" uri="ws://localdev:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> 
    <transportConnector name="mqtt+ws" uri="ws://localdev:1884?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> 
    <transportConnector name="vm" uri="vm://localdev" /> 
</transportConnectors> 

这是我们camel.xml:

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

    <camelContext id="camel" depends-on="broker-localdev" xmlns="http://camel.apache.org/schema/spring"> 
     <route id="devRawMap"> 
      <description>Redirect for test message</description> 
      <from uri="activemq:topic:alpha.topic.DEV.INTERNAL.*.RAW"/> 
      <to uri="activemq:queue:alpha.queue.DEV"/> 
     </route> 
     <route id="liveMap"> 
      <description>Redirect for Live data</description> 
      <from uri="activemq:topic:devRoot.topic.LIVE.*.RAW"/> 
      <to uri="activemq:queue:devRoot.queue.LIVE"/> 
     </route> 
    </camelContext> 

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" > 
     <property name="connectionFactory"> 
      <bean class="org.apache.activemq.ActiveMQConnectionFactory"> 
       <property name="brokerURL" value="vm://localdev?create=false"/> 
       <property name="userName" value="user"/> 
       <property name="password" value="pass"/> 
      </bean> 
     </property> 
    </bean> 
</beans> 

无论配置我做,该消息将不会从话题路由排队,我也得到了日志消息:

Broker localhost not started so using localdev instead 
Connector vm://localhost started 

我按照这个错误的方法吗?

任何帮助,高度赞赏

[编辑01]

是问题也许在很多的持久性主题beingh从kahadb alogn配置采用RuntimeConfigurationPlugin有? 需要一段时间才能加载和创建所有主题,尤其是将log4j设置为调试。 此外,RuntimeConfigurationPlugin需要代理在初始化期间设置“start = false”。看到here

+0

你可以试一下''?另外,请尝试启用完整的调试日志记录,以查看是否可以提取更多的 信息。 – Lucky

+0

你正在使用哪个版本的骆驼。当你启动应用程序时,在你的activemq上创建队列? – pvpkiran

+0

嗨,所有队列和主题都已创建。我可以从外部nodejs脚本发送给他们,也可以通过stomp连接读取队列。但是当我启动Camel时,我在日志vm:// localhost中看到正在创建。 – MPH

回答

0

您的进口<import resource="camel.xml"/>必须是经纪人和豆类元素这样之间如果camel.xml是在同一文件夹比activemq.xml

</broker> 
    <import resource="camel.xml"/> 
</beans> 

通过删除<import resource="camel.xml"/>,直接加入camel.xml内容到activemq.xml通过删除<beans>元素:

</broker> 
    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" depends-on="broker-localdev" > 
     <route id="devRawMap"> 
      <description>Redirect for test message</description> 
      <from uri="activemq:topic:alpha.topic.DEV.INTERNAL.*.RAW"/> 
      <to uri="activemq:queue:alpha.queue.DEV"/> 
     </route> 
     <route id="liveMap"> 
      <description>Redirect for Live data</description> 
      <from uri="activemq:topic:devRoot.topic.LIVE.*.RAW"/> 
      <to uri="activemq:queue:devRoot.queue.LIVE"/> 
     </route> 
    </camelContext> 

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" > 
     <property name="connectionFactory"> 
      <bean class="org.apache.activemq.ActiveMQConnectionFactory"> 
       <property name="brokerURL" value="tcp://localhost:61616"/> 
       <property name="userName" value="user"/> 
       <property name="password" value="pass"/> 
      </bean> 
     </property> 
    </bean> 
</beans> 
+0

我照你说的做了,现在它抛出一个异常:来自class path资源[camel.xml]的XML文档中的第1行是无效的;找不到元素'camelContext'的声明。但我的模式位置包括'http://camel.apache.org/schema/spring http:// camel.apache.org/schema/spring/camel-spring.xsd' – MPH

+0

我已经更新了我的答案,如果你想验证所有目的地是否由Camel创建,您需要在AMQ启动之后以及任何其他客户端连接之前对其进行验证,因为任何生产者或消费者都可以创建它们 –

+0

也许这是一个暗示,在我尝试编辑之前:我发送消息的那一刻到监视队列的日志状态发布:vm:// localhost for broker transport URI:vm:// localhost | org.apache.activemq.broker。TransportConnector | ActiveMQ VMTransport:vm:// localhost#5' – MPH