When you work with a JMS broker that is accessed through JNDI, you only need to make sure that Spring is going to be able to resolve a String representing the javax.jms.Destination
to the actual Destination.
Spring does that with DestinationResolver
. Since you have configured Spring to connect to your JMS broker, you must have a JNDI configuration somewhere (either through the use of jndi.properties
or some other form). And you can easily create a JndiTemplate
with it if that's not the case already
Once you have that, you need to define a bean as follows, assuming the JndiTemplate
bean is available with name jndiTemplate
:
@Bean
public JndiDestinationResolver destinationResolver() {
JndiDestinationResolver destinationResolver = new JndiDestinationResolver();
destinationResolver.setJndiTemplate(jndiTemplate());
return destinationResolver;
}
or
<bean id="destinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
<property name="jndiTemplate" ref="jndiTemplate"/>
</bean>
Then you need to configure this destinationResolver instead of the default. You can do that on JmsTemplate
and on the message listener container (check the destinationResolver
or destination-resolver
property).
The name of your queue or topic is the jndi entry. Chekc the JNDI name that you have used in JBoss to lookup it from your Spring-based code.