Apache Camel中的直接处理

Der*_*rek 3 java activemq-classic jms apache-camel

我有兴趣找出在Apache Camel中直接处理的最佳方法.

我有几个不同的组件,我可以在同一个JVM中启动,它与我的activemq代理分开.是否有意义尝试设置它以便我的消息从一个组件传递到下一个组件,按顺序阻塞?我将如何设置camel以确保每条消息在下一条消息启动之前到达路径中的每个组件?

更具体一点:我想通过我的brokerURI配置来做到这一点.我看到了这个页面:http: //fusesource.com/wiki/display/ProdInfo/Understanding+the+Threads+Allocated+in+ActiveMQ但我不确定在哪里/如何实现选项 - optimizedDispatch似乎对代理有效destinationPolicy选项.

谢谢

Ben*_*Day 5

首先,明确配置路由中使用队列的单个消费者...

要么全局连接所有连接

<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="connectionFactory" ref="pooledConnectionFactory"/>
    <property name="concurrentConsumers" value="1"/>
    <property name="maxConcurrentConsumers" value="1"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

或明确按路线/消费者

 from("activemq:queue:input?concurrentConsumers=1&maxConcurrentConcumers=1")...
Run Code Online (Sandbox Code Playgroud)

那么,你有几个选择.通常,您要么使用管道模式在单个路由中的步骤(同步)之间传递消息.或者使用camel-direct在多个路由之间提供同步消息流.

from("activemq:queue:input?concurrentConsumers=1&maxConcurrentConcumers=1")
    .to(<step1>)
    .to(<step2>)
    ...
Run Code Online (Sandbox Code Playgroud)

或者如果您的步骤需要多条路线,请使用直接连接它们...

from("activemq:queue:input?concurrentConsumers=1&maxConcurrentConsumers=1")
    .to("direct:step1");

from("direct:step1")
    //perform step1 processing
    .to(direct:step2");

from("direct:step2")
    //perform step2 processing
    .to(direct:step3");
...
Run Code Online (Sandbox Code Playgroud)