Hi Glad you found a nice solution. I thought about the <choice> tag as well tonight but you had the solution already.
I guess there is also the *dynamic* reciepentlist that can do exactly what you want: http://activemq.apache.org/camel/recipient-list.html But then you need to have the endpoint URI's in your java code. And in fact I don't know if you can just the endpoint ref's as you have now. But I am pretty sure. <recipientList> <xpath>$queueid</xpath> </recipientList> However the queueid should contain either output1, output2 or output3. Med venlig hilsen Claus Ibsen ...................................... Silverbullet Skovsgårdsvænget 21 8362 Hørning Tlf. +45 2962 7576 Web: www.silverbullet.dk -----Original Message----- From: buchnerm [mailto:[EMAIL PROTECTED] Sent: 17. juli 2008 17:47 To: [email protected] Subject: Re: How to route a message based on a criteria?? hi - I found a solution for this issue: I created a processor which adds a header field "queueid" and the value of sessionid % x Code of the processor: ************************************************* public class HeaderProcessor<T extends AbstractBase> implements Processor, ParamDefinitions { private int numberOfConsumers; public void process(Exchange exchange) throws Exception { ObjectImpressionTransportBean transportBean = (ObjectImpressionTransportBean)(exchange.getIn().getBody()); String sessionid = transportBean.getSensorCall().getParameter().get(PARAMETERKEY_SESSIONID); if (sessionid != null) { int queueid = sessionid.hashCode()%numberOfConsumers; exchange.getOut().setHeader("queueid", Integer.toString(queueid)); } else { exchange.getOut().setHeader("queueid", "0"); } } public int getNumberOfConsumers() { return numberOfConsumers; } public void setNumberOfConsumers(int numberOfConsumers) { this.numberOfConsumers = numberOfConsumers; } } ************************************************* then I use the "choice" tag to redirect the messages: Code of the route: ************************************************* <endpoint id="input1" uri="${jms.bean}:${jms.OIConveyerQueue}?concurrentConsumers=${jms.concurrentConsumers}"/> <endpoint id="output1" uri="${jms.bean}:${jms.SessionManagerQueue1}"/> <endpoint id="output2" uri="${jms.bean}:${jms.SessionManagerQueue2}"/> <endpoint id="output3" uri="${jms.bean}:${jms.SessionManagerQueue3}"/> <route> <from ref="input1" /> <to uri="queueSwitchProcessor" /> <!-- <to uri="gateOut" />--> <choice> <when> <xpath>$queueid = "0"</xpath> <to ref="output1"/> </when> <when> <xpath>$queueid = "1"</xpath> <to ref="output2"/> </when> <otherwise> <to ref="output3"/> </otherwise> </choice> </route> ....... <bean id="queueSwitchProcessor" class="com.fatwire.analytics.camel.processor.HeaderProcessor"> <property name="numberOfConsumers" value="3"/> <!-- number of consumers --> </bean> ************************************************* -- View this message in context: http://www.nabble.com/How-to-route-a-message-based-on-a-criteria---tp18506590s22882p18511610.html Sent from the Camel - Users mailing list archive at Nabble.com.
