JMS Spring Selector Magic

I was happy to discover that Spring makes it so easy to select jms messages from a queue using the message’s header field values and property values. Just add in your own messageSelector expression <property name=”messageSelector” value=”Jurisdiction = ‘BC'” />. See http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Message.html for more explanation of the expression syntax.

<bean id="brokerRequestNotificationMessageContainer" class="org.springframework.jms.listener.SimpleMessageListenerContainer102">
	<property name="connectionFactory" ref="brokerConnectionFactory" />
	<property name="destination" ref="ehrBrokerRequestQueue" />
	<property name="messageListener" ref="requestMessageListener" />
	<property name="concurrentConsumers" value="${ehr.broker.request.queue.consumers}" />
	<property name="messageSelector" value="Jurisdiction = 'BC'" />
</bean>

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply