How to filter jms message in apache camel xml configuration file

1.4k views Asked by At

I wish to create jms subscriber on a general topic. to avoid unwanted messages i wish to create a filter there. the problem is the syntax is available every where from java code but I can not find how to do same in xml configuration file like blueprint.xml

Java code

String redSelector = "color='red'";
MessageConsumer redConsumer = redSession.createConsumer(queue, redSelector);

Apache camel route

<route id="externalNotificationsDispatchRoute" >
  <from uri="activemq:queue:{{vqueue.name}}" />
  .. filtering part
  <to uri="log:com?level=DEBUG" />
</route>
1

There are 1 answers

0
Bedla On

JMS Message Selector is specified with selector URI parameter.

Blueprint:

<from uri="activemq:queue:{{vqueue.name}}?selector={{vqueue.selector}}" />

Property file:

vqueue.selector=color%3D'red'

Refer JMS component documentation (ActiveMQ component iherits the parameters from the JMS component)

selector

Sets the JMS Selector, which is an SQL 92 predicate that is used to filter messages within the broker. You may have to encode special characters like '=' as %3D.