Question

I have a Spring app running inside a standalone JBoss EAP 6.2 (with its embedded HornetQ provider).

Messages are succcesfully put on the queue (I can see them in jboss-eap-6.2\standalone\data\messagingjournal\hornetq-data-1.hq because the queue is durable), but not picked up by the listener (a breakpoint inside the listener is not hit). I suspect something is missing from or wrong in the configuration but cannot see what. JBoss starts without any validation errors.

First, the excerpt from Spring's applicationContext.xml:

The JNDI names of the connection factory and queue match those in JBoss' standalone-full.xml

<jee:jndi-lookup id="jmsConnectionFactory" jndi-name="java:/JmsXA" resource-ref="false" proxy-interface="javax.jms.ConnectionFactory"/> 

<jee:jndi-lookup id="myQueue" jndi-name="java:jboss/exported/jms/queue/myQueue"/> 

<bean id="myHandler" class="com.example.MyHandler" />

<jms:listener-container destination-type="queue" acknowledge="auto" connection-factory="jmsConnectionFactory">
    <jms:listener destination="java:jboss/exported/jms/queue/myQueue" ref="myHandler" method="processMessage" />
</jms:listener-container>

The message handler is declared as a Spring component and the class and method names match what is declared above:

@Component
public class MyHandler {

public void processMessage(MyMessage delaySendTransfer) {
    //...
}
Was it helpful?

Solution

By default, Spring use the DynamicDestinationResolver for the listener container so it expects to receive a bean reference in the destination attribute of the listener. Since you are using a JNDI name, you should set the destination resolver strategy to jndiDestinationResolver.

<jms:listener-container destination-resolver="jndiDestinationResolver" destination-type="queue" acknowledge="auto" connection-factory="jmsConnectionFactory">
    <jms:listener destination="java:jboss/exported/jms/queue/myQueue" ref="myHandler" method="processMessage" />
</jms:listener-container>

Replacing the destination attribute value with the bean reference should also do the trick :

<jms:listener-container destination-type="queue" acknowledge="auto" connection-factory="jmsConnectionFactory">
    <jms:listener destination="myQueue" ref="myHandler" method="processMessage" />
</jms:listener-container>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top