Reputation: 415
I am using the below configuration for Message listener:
<bean id="container"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="autoStartup" value="true" />
<property name="connectionFactory" ref="connectionFactory" />
<property name="destinationName" value="queue.name" />
<property name="pubSubDomain" value="true" />
<property name="pubSubNoLocal" value="true" />
<property name="durableSubscriptionName" value="subscription.id" />
<property name="subscriptionDurable" value="true" />
<property name="concurrency" value="1" />
<property name="messageSelector" value="Trade IS NOT NULL" />
<property name="sessionTransacted" value="true" />
</bean>
In Message Selector, Trade is referring to the tag Name in XML that I am supposed to receive via JMS.
This is not working. I have searched a lot. I didn't get many clues on how to put this condition in message selector.
Upvotes: 0
Views: 986
Reputation: 174729
No.
See the message selector tutorial (google: "jms message selector tutorial").
Specifically:
The message consumer then receives only messages whose headers and properties match the selector. (See Message Headers, and Message Properties.) A message selector cannot select messages on the basis of the content of the message body.
You can't select on arbitrary messsage content. You need to have the sender add the content of the tag as a message property before sending.
EDIT:
Please don't use old documentation references; use the current docs or the latest documentation can always be found on the project page
To filter using Spring Integration (after consumption), you can use an XPathFilter:
<int-xml:xpath-filter id="booleanFilter" input-channel="booleanFilterInput" discard-channel="booleanFilterRejections">
<si-xml:xpath-expression expression="/foo/bar"/>
</int-xml:xpath-filter>
This will pass any <foo>...</foo>
documents that have a <bar>...</bar>
child element and reject those that don't (or are not foos).
Upvotes: 2