I am interested in figuring out the best way to do straight through processing in Apache Camel.
I have several different components that I am able to start up in the same JVM, which is separate from where my activemq broker. Does it make sense to try to set it up so that my messages get passed from one component to the next, in order, blocking? How would I go about setting camel up to ensure that each message hits every component along the route before the next message is started?
To be more specific: I would like to do this through a configuration of my brokerURI or something. I saw this page: http://fusesource.com/wiki/display/ProdInfo/Understanding+the+Threads+Allocated+in+ActiveMQ but I am not sure where/how to implement the options - optimizedDispatch seemed to work on the broker destinationPolicy options.
Thanks
to start, explicitly configure a single consumer in your routes that consume from queues...
either globally for all connections
<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>
or explicitly per route/consumer
from("activemq:queue:input?concurrentConsumers=1&maxConcurrentConcumers=1")...
then, you have a few options. generally, you'd either use a pipeline pattern to pass messages between steps (synchronously) in a single route. Or use camel-direct to provide synchronous message flow between multiple routes.
from("activemq:queue:input?concurrentConsumers=1&maxConcurrentConcumers=1")
.to(<step1>)
.to(<step2>)
...
or if your steps require multiple routes, then connect them using direct...
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");
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With