1

I have a web application that connects to multiple jms servers (one at the time) and monitors queues. While this is simple for one jms server I do not know how to configure it for multiple servers. I want user to be able to choose the server at logging in and only then I want JmsListener to monitor queues. User also must be able to change the server while he's already logged in. The problem is how to create and change configuration of these beans at runtime. At the moment my solution is hard-coded like this:

JmsConfig.class

    @Bean
    public TibjmsConnectionFactory receiverTibjmsConnectionFactory() {
        TibjmsConnectionFactory factory=new TibjmsConnectionFactory("myip");
        factory.setUserName("username");
        factory.setUserPassword("password");
        return factory;
    }   
    @Bean
    public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
        DefaultJmsListenerContainerFactory factory=new DefaultJmsListenerContainerFactory();
        factory.setConnectionFactory(receiverTibjmsConnectionFactory());
        factory.setPubSubDomain(true);
        return factory;
    }

EmsListener.class

@Component
public class JmsListener {  
    @org.springframework.jms.annotation.JmsListener(destination="$sys.monitor.Q.r.>")
    public void receive(Message message) throws JMSException {
            System.out.println("MY MESSAGE IS : "+message.getJMSTimestamp());
    }
}
wisnix
  • 180
  • 1
  • 8
  • 1
    Does this answer your question? [Adding Dynamic Number of Listeners(Spring JMS)](https://stackoverflow.com/questions/34063230/adding-dynamic-number-of-listenersspring-jms) – Justin Bertram Feb 17 '20 at 19:30
  • No, I want to configure multiple servers and switch them at runtime, not destinations. – wisnix Feb 18 '20 at 09:34

0 Answers0