spring-bootspring-jmstibco-emsaws-vpn

Spring boot JMS DefaultListenerContainer occasionally drops connection and not autorevocered with Tibco EMS


Issue is similar to the one mentioned at Spring JMS Consumers to a TIBCO EMS Server expire on their own and have to restart our spring boot application to restablish the connection

and below is the code snippet we are using for Listener configuration

    public JmsListenerContainerFactory jmsListenerContainerFactory() {
        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
        factory.setConnectionFactory(connectionFactory());

        factory.setMaxMessagesPerTask(5);
        factory.setConcurrency("5");
        return factory;
    }

And connection factory

@Bean
    public ConnectionFactory connectionFactory() {
        ConnectionFactory connectionFactory = null
        Tibjms.setPingInterval(10);
        try {
            TibjmsConnectionFactory tibjmsConnectionFactory = new TibjmsConnectionFactory(
                        environment.getProperty("url"));
            //few more statments to set other properties    
            
        } catch (Exception ex) {
            
        }
        return connectionFactory;
    }

Issue is observed during vpn failovers, we have active and failover vpn connection,when VPN switches, at application end netstat shows connection is established but at EMS end netstat indicates that connection is terminated or not found after few minutes, indicating no listener at EMS end.

We are using DefaultListnerContainer factory which supposed to poll and refresh connection if connection is terminated but unable to do so and have to restart the server

We suspect due to some configuration issues at VPN end, DefaultListnerContainer is not able to identify that connection has been terminated and unable to refresh JMS connection.

Please let me know if there are any other parameters or properties that can help DefaultListnerContainer to identify such scenarios.


Solution

  • If you look at the TIBCO EMS documentation : https://docs.tibco.com/pub/ems/8.5.1/doc/html/api/javadoc/com/tibco/tibjms/TibjmsConnectionFactory.html

    You can see that there are parameters to manage reconnections :

    setConnAttemptCount(int attempts) 
    setConnAttemptDelay(int delay) 
    setConnAttemptTimeout(int timeout)
    setReconnAttemptCount(int attempts) 
    setReconnAttemptDelay(int delay) 
    setReconnAttemptTimeout(int timeout)
    

    As an example you can use following values (delay and timeout are in msec):

    setConnAttemptCount(int attempts)   60 
    setConnAttemptDelay(int delay)   2000
    setConnAttemptTimeout(int timeout) 1000
    setReconnAttemptCount(int attempts)  120
    setReconnAttemptDelay(int delay)  2000
    setReconnAttemptTimeout(int timeout) 1000
    

    You can also define reconnection parameters in the Connection Factory definition, for example :

    [QueueConnectionFactory]
    type                     = queue
    url                      = tcp://serveur1:7222,tcp://serveur2:7222
    connect_attempt_count    = 60
    connect_attempt_delay    = 2000
    connect_attempt_timeout  = 1000
    reconnect_attempt_count  = 120
    reconnect_attempt_delay  = 2000
    reconnect_attempt_timeout= 1000
    

    You may adjust values of the parameters to manage network issues that would last a long time.

    Note also to make for the EMS client library to detect the loss of the connection to the EMS and trigger the reconnection mechanisms you need to have the following parameters in the EMS tibemsd.conf file (duration in seconds here):

    client_heartbeat_server                   = 20
    server_timeout_client_connection          = 90
    server_heartbeat_client                   = 20
    client_timeout_server_connection          = 90
    

    The above should resolve your issue but I recommend to do test to adjust the values of the reconnection parameters