On 07/02/2008, Jar Lyons <[EMAIL PROTECTED]> wrote: > > I have been trying for days now to get a message based router working in > ActiveMQ 5.1, and the only success I have had is with xpath. > > Unfortunately, xpath will only work when the message body is xml ... which > often is not the case for me. > > Here is an example of what does work (assuming the message body is xml): > > <route> > <from uri="activemq:queue.dev.Tideworks.HelloWorld"/> > <filter> > <xpath>$JMSType = 'Tideworks.GateVision.OCR.Lane'</xpath> > <to uri="activemq:queue.dev.Tideworks.HelloWorld"/> > </filter> > </route> > > So ... once I realized this only works with fully xml message bodies, I > tried all of the following, with no luck ... > > <route> > <from uri="activemq:queue.dev.Tideworks.HelloWorld"/> > <filter> > <simple>property.JMSType = 'Tideworks.GateVision.OCR.Lane'</simple> > <to uri="activemq:queue.dev.Tideworks.HelloWorld.it_works"/> > </filter> > </route> > > <route> > <from uri="activemq:queue.dev.Tideworks.HelloWorld"/> > <filter> > <el>in.headers.jmstype startswith 'Tideworks'</el> > <to uri="activemq:queue.dev.Tideworks.HelloWorld.it_works"/> > </filter> > </route> > > All of the above configurations will load and run without throwing > exceptions, but only the xpath example will do what I want. And again, I > need to be able to operate with non-xml messages. > > In the ideal world, I would use a filter that allows me to use the same > style JMS selector expressions that a developer would be accustomed to using > when configuring a MessageDrivenBean. > > I must be missing something very obvious here ....
I guess one option could be to add JMS SQL selector syntax into the filter as a language, which wouldn't be too hard. For non-XML payloads then EL is probably the best choice (or OGNL if you know its syntax). Its mostly a question of getting the EL expression correct for what you need. Maybe a little JUnit test case can help you experiment with EL expression (e.g. see the JuelLanguageTest in the camel-juel module for a place you can experiment). FWIW I thought JUEL had method invocation enabled by default - it turns out it doesn't :). I've just raised this issue... https://issues.apache.org/activemq/browse/CAMEL-347 its now been fixed in trunk; so you can use expressions like: ${in.headers.foo.startsWith('a')} with JUEL and it works with method calls. Note with EL you use ${} around the dyamic bits - as JUEL can be used to create Strings too. e.g. the following is valid JUEL <el>hello ${in.header.name} how are you?</el> -- James ------- http://macstrac.blogspot.com/ Open Source Integration http://open.iona.com
