简体   繁体   中英

Spring MDP not following JMS priority

I have a JMS Client that is sending messages to a Weblogic Queue with priority. To keen matters simple we have 2 priorities set 0 & 9.

On the Server end we have a Spring Application (with a Spring MDP - Message Driven Pojo) deployed on that Queue. Here is the Spring Bean Declaration:

<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="concurrentConsumers" value="20" />
    <property name="connectionFactory" ref="jmsFactory" />
    <property name="destination">
        <bean class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiTemplate" ref="jndiTemplate" />
            <property name="jndiName" value="${jms.inbound.queue}" />
        </bean>
    </property>
    <property name="messageListener" ref="appMessageListener" />
</bean>

appMessageListener - Is the class that implements Message listener and has the onMessage method.

TESTING: STOP the application and send 40 requests 20 with priority 0 and 20 with priority 9. START the application.

Expect result is that the MDP should pick and process priority 9 messages first then priority 0 messages.

In reality messages are being picked and processed in random (Most probable the order they came in)

To check if the priority was set or not we print JMSMEssage.getPriority() inside the JMS Listener's onMessage method and it prints the priorities correctly (mix of 20 P9 and 20 P0)

Is the spring DefaultMessageListenerContainer not able to handle JMS Priority ?

Any pointers on this will be appreciated.

App details - Weblogic 11g, Java 1.6, Spring 3.0. All Queues have file stores.

Silly me, I did not configure destination keys for sorting.

If any one comes to this thread doing same goof up as me, read this: Here is how to do it In the Administration Console, navigate to the destination key resource that you want to configure: Navigate to JMS Resources in System Modules Navigate to JMS resources in an application module On the Configuration > General tab: o In Sort Key, select a message sort key name or the name of a message header field on which to sort. (Sort Key - The message sort key or the name of a message header field on which to sort. Message header field keys start with the letters JMS and ignore the key type setting. Attribute: Property to be set to: JMSPriority

And it works !!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM