I should be able to configure multiple JmsListenerContainerFactory beans from multiple JMS JNDI names configured in the server and I should be able to do the following.
@EnableJms
@Configuration
public class JmsConfig
{
@Bean
public JmsListenerContainerFactory<?> containerFactoryONE(@Qualifier("from-JNDI-ONE") ConnectionFactory connectionFactory,
DefaultJmsListenerContainerFactoryConfigurer configurer)
{
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
configurer.configure(factory, connectionFactory);
return factory;
}
@Bean
public JmsListenerContainerFactory<?> containerFactoryTWO(@Qualifier("from-JNDI-TWO") ConnectionFactory connectionFactory,
DefaultJmsListenerContainerFactoryConfigurer configurer)
{
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
configurer.configure(factory, connectionFactory);
return factory;
}
}
and should be able to listen to the message from two different servers as below
@Component
public class JMSListener
{
@JmsListener(destination = "jms/ActiveMQ-Server-ONE", containerFactory="containerFactoryONE")
public void receiveMessageFromJMSServerONE(String message)
{
System.out.println(message);
}
@JmsListener(destination = "jms/ActiveMQ-Server-TWO", containerFactory="containerFactoryTWO")
public void receiveMessageFromJMSServerTWO(String message)
{
System.out.println(message);
}
}