I have a requirement to add multiple listeners as mentioned in the application.properties file. Like Below,
InTopics=Sample.QUT4,Sample.T05,Sample.T01,Sample.JT7
NOTE: This number can be lot more or less.
I am thinking of getting them in an array,
@Value("${InTopics}")
private String[] inTopics;
But i don't know how to create multiple listeners from the array.
Currently, for one Topic i am doing as below,
@Configuration
@EnableJms
public class JmsConfiguration {
@Value("${BrokerURL}")
private String brokerURL;
@Value("${BrokerUserName}")
private String brokerUserName;
@Value("${BrokerPassword}")
private String brokerPassword;
@Bean
TopicConnectionFactory connectionFactory() throws JMSException {
    TopicConnectionFactory connectionFactory = new TopicConnectionFactory(brokerURL, brokerUserName, brokerPassword);
    return connectionFactory;
}
@Bean
JmsListenerContainerFactory<?> jmsContainerFactory(TopicConnectionFactory connectionFactory) throws JMSException {
    SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setPubSubDomain(Boolean.TRUE);
    return factory;
 }
}
And My Listener,
@JmsListener(destination = "${SingleTopicName}", containerFactory = "jmsContainerFactory")
public void receiveMessage(Message msg) {
   //Do Some Stuff
}
Is there any way i can achieve this?
 
     
     
     
    