Reputation: 71
I'm new to Camel and looking to find an option to filter JMS topic msgs, based on the body content. I looked at different languages for filtering, like simple, OGNL, groovy etc, but unable to figure out how it can be applied for content based filtering Here's an example of the JMS msg/content I need to filter from -
"created_at":"Wed Sep 11 14:48:38 EDT 2013","text":"habra que ir pensando en cambiar el iphone...","id":"377866287525138432"
Filtering criteria should be "text" or body() contains "iphone" (ignorecase) Something like -
from("activemq:topic:MyTopic")
.filter().ognl(getRequest().getBody().???)
.to("file:/abc/?fileName=abcFile.txt&autoCreate=true&fileExist=Append")
Any thoughts/suggestions will be greatly appreciated.
Thanks!!!
Upvotes: 1
Views: 4665
Reputation: 429
You may also try out http://camel.apache.org/content-based-router.html for content based routing. This will help if you have a choice of multiple destinations to route the message based on the content.
from("jms:topic:MyTopic")
.choice()
.when(body().contains('iphone'))
.to("direct:b")
.otherwise()
.to("direct:d");
Upvotes: 1
Reputation: 55750
I suggest to take a moment to read the Camel documentation, such as
And since you use OGNL then read http://camel.apache.org/ognl.html - there is some examples. Eg notice that the OGNL script must be provided as a String parameter, so your example should be something alike:
.filter().ognl("getRequest().getBody().contains('iphone')")
Though it could possible be shorter
.filter().ognl("request.body.contains('iphone')")
Upvotes: 2