I have the following route which takes an input message (with header
type="INPUT") and splits it into two (with header type="TYPE1" and "TYPE2"),
after which a choice is used to route it to the appropriate endpoint based
on a 'type' header value set in the splitter.
When using the <simple> expression in the choice it is evaluating the
original message in each case and not split one and hence checks fail and I
send to error queue.
When using the same check in an equivalent <javaScript> expression it is
correctly evaluating the split message in each case and so correctly routes
to the out queues.
<route>
<from uri="jms:IN_QUEUE"/>
<split>
<!-- Splits input msg into two; one with header.type=TYPE1 and the other
with TYPE2 -->
<method bean="MySplitter" method="doSplit"/>
<choice>
<when>
<simple>${header.type} == 'TYPE1'</simple> <!-- why is
this not working?
-->
<!--javaScript>request.headers.get('type') ==
'TYPE1'</javaScript-->
<to uri="jms:OUT_QUEUE_1" />
</when>
<when>
<simple>${header.type} == 'TYPE2'</simple> <!-- why is
this not working?
-->
<!--javaScript>request.headers.get('type') ==
'TYPE2'</javaScript-->
<to uri="jms:OUT_QUEUE_2" />
</when>
<otherwise>
<to uri="jms:ERROR"/>
</otherwise>
</choice>
</split>
</route>
Here is my log and tracer output when using <simple> checks (I added a
little extra debug output into PredicateBuilder to show what it is exactly
comparing);
INFO [RouteTest ] - Expected message count
OUT_QUEUE_1=1, OUT_QUEUE_2=1, ERROR=0
INFO [RouteTest ] - Sent exchange: Exchange[Message: ]
INFO [Logger ] - ID-mswxp2-2741-1248881378187-2-0
>>> jms:IN_QUEUE --> split(), Pattern:InOnly, Headers:{JMSXGroupID=null,
JMSCorrelationID=null, JMSType=null, JMSExpiration=0,
JMSMessageID=ID:mswxp2-2739-1248881377921-0:4:1:1:1, JMSRedelivered=false,
JMSDeliveryMode=2, JMSPriority=4, type=INPUT, JMSReplyTo=null,
JMSTimestamp=1248881378765, JMSDestination=queue://IN_QUEUE},
BodyType:String, Body:
INFO [Logger ] - ID-mswxp2-2741-1248881378187-2-0
>>> split() --> split(), Pattern:InOnly, Headers:{CamelMulticastIndex=0,
CamelSplitSize=2, type=TYPE1, CamelSplitIndex=0}, BodyType:String, Body:
TRACE [PredicateBuilder$6 ] - matches(INPUT==TYPE1)
TRACE [PredicateBuilder$6 ] - matches(INPUT==TYPE2)
INFO [Logger ] - ID-mswxp2-2741-1248881378187-2-0
>>> split() --> otherwise(jms:ERROR), Pattern:InOnly,
Headers:{CamelMulticastIndex=0, CamelSplitSize=2, type=TYPE1,
CamelSplitIndex=0}, BodyType:String, Body:
INFO [Logger ] - ID-mswxp2-2741-1248881378187-2-0
>>> otherwise(jms:ERROR) --> split(), Pattern:InOnly,
Headers:{CamelMulticastIndex=1, CamelSplitSize=2, type=TYPE2,
CamelSplitIndex=1}, BodyType:String, Body:
TRACE [PredicateBuilder$6 ] - matches(INPUT==TYPE1)
TRACE [PredicateBuilder$6 ] - matches(INPUT==TYPE2)
INFO [Logger ] - ID-mswxp2-2741-1248881378187-2-0
>>> split() --> otherwise(jms:ERROR), Pattern:InOnly,
Headers:{CamelMulticastIndex=1, CamelSplitSize=2, type=TYPE2,
CamelSplitIndex=1}, BodyType:String, Body:
INFO [RouteTest ] - Got message count OUT_QUEUE_1=0,
OUT_QUEUE_2=0, ERROR=2
and here is the same test when using <javaScript> checks;
INFO [RouteTest ] - Expected message count
OUT_QUEUE_1=1, OUT_QUEUE_2=1, ERROR=0
INFO [RouteTest ] - Sent exchange: Exchange[Message: ]
INFO [Logger ] - ID-mswxp2-2801-1248882234296-2-0
>>> jms:IN_QUEUE --> split(), Pattern:InOnly, Headers:{JMSXGroupID=null,
JMSCorrelationID=null, JMSType=null, JMSExpiration=0,
JMSMessageID=ID:mswxp2-2799-1248882234046-0:4:1:1:1, JMSRedelivered=false,
JMSDeliveryMode=2, JMSPriority=4, type=INPUT, JMSReplyTo=null,
JMSTimestamp=1248882234890, JMSDestination=queue://IN_QUEUE},
BodyType:String, Body:
INFO [Logger ] - ID-mswxp2-2801-1248882234296-2-0
>>> split() --> split(), Pattern:InOnly, Headers:{CamelMulticastIndex=0,
CamelSplitSize=2, type=TYPE1, CamelSplitIndex=0}, BodyType:String, Body:
INFO [Logger ] - ID-mswxp2-2801-1248882234296-2-0
>>> split() --> when(request.headers.get('type') == 'TYPE1'),
Pattern:InOnly, Headers:{CamelMulticastIndex=0, CamelSplitSize=2,
type=TYPE1, CamelSplitIndex=0}, BodyType:String, Body:
INFO [Logger ] - ID-mswxp2-2801-1248882234296-2-0
>>> when(request.headers.get('type') == 'TYPE1') --> split(),
Pattern:InOnly, Headers:{CamelMulticastIndex=1, CamelSplitSize=2,
type=TYPE2, CamelSplitIndex=1}, BodyType:String, Body:
INFO [Logger ] - ID-mswxp2-2801-1248882234296-2-0
>>> split() --> when(request.headers.get('type') == 'TYPE2'),
Pattern:InOnly, Headers:{CamelMulticastIndex=1, CamelSplitSize=2,
type=TYPE2, CamelSplitIndex=1}, BodyType:String, Body:
INFO [RouteTest ] - Got message count OUT_QUEUE_1=1,
OUT_QUEUE_2=1, ERROR=0
This is causing us to not be able to use the Simple language header
checking, which is a shame because of the simplicity and the performance
benefits it provides.
Am I doing something dumb here, or does this look like an issue I should
raise? I'm using 2.0-M2, btw.
Thanks
Mark
--
View this message in context:
http://www.nabble.com/Simple-language-checks-failing-after-split-tp24722130p24722130.html
Sent from the Camel - Users mailing list archive at Nabble.com.