Spring's DefaultMessageListenerContainer Not Failing Over to Secondary URL

46 Views Asked by At

We have a Spring application that requires a Tibco EMS topic consumer and uses the org.springframework utilities for JMS support and uses the spring-jms-5.2.24.RELEASE.jar version of Spring JMS.

We configure the URL with two addresses for failover.

    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
       <property name="environment">
          <props>
             <prop key="java.naming.provider.url">tcp://usitdjms-vd3:7222,tcp://usitdjms-vd4:7222</prop>
             <prop key="java.naming.factory.initial">com.tibco.tibjms.naming.TibjmsInitialContextFactory</prop>
             <prop key="java.naming.security.principal">${USERNAME}</prop>
             <prop key="java.naming.security.credentials">${PASSWORD}</prop>
          </props>
       </property>
    </bean>

However, when we bring down the vd3 server the code does not failover to vd4. Instead an error is printed continuously and the problem will only resolve when restarting the application.

08/15/2023-14:20:19:453 [jmsContainer-1] - ERROR - DefaultMessageListenerContainer.java:962 - Could not refresh JMS Connection for destination 'Topic[in_order_perf]' - retrying using FixedBackOff{interval=5000, currentAttempts=54, maxAttempts=unlimited}. Cause: Failed to connect to the server at tcp://usitdjms-vd4.ny.cantor.com:7222; nested exception is java.net.ConnectException: Connection refused (Connection refused)

How do I use Spring's implementation of JMS such that the above two URLS are tried in a round-robin way? We don't want to have to restart our application if the primary JMS server goes down.

If vd3 fails to connect then vd4 should become connected and vice versa.

0

There are 0 best solutions below