0

I have my application that should communicate with two external systems A and B. So I am creating actually 2 containers like this:

private DefaultMessageListenerContainer createContainer(Conf conf) {
    DefaultMessageListenerContainer jmsCnr= new DefaultMessageListenerContainer();
    jmsCnr.setConnectionFactory(connectionFactoryAdapter);
    jmsCnr.setDestinationResolver(destinationResolver);
    jmsCnr.setDestinationName(destinationName);
    jmsCnr.setMessageListener(MyClass);
    jmsCnr.initialize();
    return jmsCnr;
}

And creation of connection factory goes like this:

 private ConnectionFactory createConnectionFactory(Conf conf) {
    JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
    JndiTemplate jndiTemplate = getJNDITemplate(conf);
    String connectionFactoryJndiName = conf.getConnectionFactoryJndi();
    jndiObjectFactoryBean.setJndiTemplate(jndiTemplate);
    jndiObjectFactoryBean.setJndiName(connectionFactoryJndiName);
    jndiObjectFactoryBean.setProxyInterface(ConnectionFactory.class);
    jndiObjectFactoryBean.setLookupOnStartup(false);
    try {
        jndiObjectFactoryBean.afterPropertiesSet();
    } catch (NamingException e) {
        e.printStackTrace();
    }
    return (ConnectionFactory) jndiObjectFactoryBean.getObject();
}

After that containers are created, I am looping over them and call start(). Everything is working fine My listener is receiving message in case if message is sent to external system A.

However if I configuring my startup class to create two containers for external system A and for B, I am not receiving messages from queues of system A, and from system B messages are received.

Again, I am using spring implementations without spring context, everything is programmatic.

My question is, where I am missing something? Seems creation of second DefaultMessageListenerContainer instance for external system B is overriding the previous.

liotur
  • 809
  • 2
  • 17
  • 36
  • If Spring does not manage the containers, as long as you call `initialize()` and `start()` all should be ok; try calling `afterPropertiesSet()` instead of `initialize()`; it checks the configuration. Also turn on DEBUG logging and compare the logs from one that works to the one the doesn't. – Gary Russell Jan 13 '19 at 17:03
  • without initialize it doesn't work. Also I see some strange thing, when I configuring two external systems in threads I see that there a few weblogic.jms.Reconnect threads. And it is trying to reconnect every few sec's. Is the way I am getting connection factory is correct? – liotur Jan 13 '19 at 17:06
  • and by the way, how could I turn on debug? – liotur Jan 13 '19 at 17:20
  • `afterPropertiesSet()` calls `initialize()` after checking the configuration. Refer to your logging subsystem (e.g. log4j, logback) documentation to enable debug logging. – Gary Russell Jan 13 '19 at 17:29
  • I added exception listener to container, now I see weblogic.jms.common.JMSException: weblogic.messaging.dispatcher.DispatcherException: weblogic.rjvm.PeerGoneException: Stale RJVM was detected – liotur Jan 13 '19 at 18:35
  • Actually it was not related to multiple external systems. Problem with reconnection. After external system (wls) restart everything is working fine, however, when I am restarting ext system, my application thread shows 'weblogic.jms.Reconnect' threads, which updated every few secs, like heartbeat. However connection is not restored. Do you know why? – liotur Jan 14 '19 at 07:56

0 Answers0