Search code examples
springapache-cameljndispring-jmssolace

camel, solace jndi configuration with spring jndi template not throwing exception when solace not reachable


I am trying to connect to solace broker using camel-jms and spring. And my micro service will consume the REST input and enqueue the solace queue.

Problem I am facing is, processing thread is waiting for the connection establishment infinitely when connectivity to the solace is broken instead of throwing an error.

And getting timeout when ever the REST service is called at client side..

Spring Configuration:

     <bean id="Solace.JndiTemplateDev"
          class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.provider.url">smf://_url_:port</prop>
                <prop key="java.naming.factory.initial">com.solacesystems.jndi.SolJNDIInitialContextFactory</prop>
                <prop key="java.naming.security.principal">xxxx</prop>
                <prop key="java.naming.security.credentials">xxxxxx</prop>
                <prop key="Solace_JMS_JNDI_ConnectRetries">0</prop>
                <prop key="Solace_JMS_JNDI_ReadTimeout">10000</prop>
                <prop key="Solace_JMS_JNDI_ReconnectRetries">2</prop>
                <prop key="Solace_JMS_JNDI_ConnectTimeout">5000</prop>
            </props>
        </property>
    </bean>

    <bean id="Solace.JndiObjectFactoryBeanDev"
          class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="Solace.JndiTemplateDev"/>
        <property name="jndiName" value="defaultConnectionFactory"/>
        <property name="lookupOnStartup" value="false"/>
        <property name="proxyInterface" value="javax.jms.ConnectionFactory"/>
    </bean>

    <bean id="Solace.CachedConnectionFactoryDev" primary="true"
          class="org.springframework.jms.connection.CachingConnectionFactory">
        <property name="targetConnectionFactory" ref="Solace.JndiObjectFactoryBeanDev"/>
        <property name="reconnectOnException" value="true"/> 
        <property name="sessionCacheSize" value="5"/>
    </bean>


    <bean id="dynamicDestinationResolverDev"
        class="org.springframework.jms.support.destination.DynamicDestinationResolver">
    </bean>

    <bean id="jmsSolaceBhPDEV" class="org.apache.camel.component.jms.JmsComponent">
        <property name="connectionFactory" ref="Solace.CachedConnectionFactoryDev"/>
        <property name="destinationResolver" ref="dynamicDestinationResolverDev"/>

    </bean>

Please find the logs.

19.11.18 22:55:30.641 DEBUG     http-nio-8080-exec-3  com.solacesystems.jms.SolSession  qa | Entering createQueue()
19.11.18 22:55:30.643  INFO     http-nio-8080-exec-3 mp.protocol.impl.TcpClientChannel  qa | TcpClientChannel:open(isReconn=false) while connected, return.
19.11.18 22:55:30.644 DEBUG     http-nio-8080-exec-3 mp.protocol.impl.TcpClientChannel  qa | doSmfSharedReq (smfclient 4) try=0 / max=1 
19.11.18 22:55:48.937  INFO Thread_reconnect_service mp.protocol.impl.TcpClientChannel  qa | Connection attempt failed to host 'abc.com' ReconnectException com.solacesystems.jcsmp.JCSMPTransportException: (Client name: localhost/19108/#00560002/xnuvPhoyFH   Local port: -1   Remote addr: abc.com:55555) - Error communicating with the router. cause: java.net.ConnectException: Connection timed out: no further information
19.11.18 22:55:51.939 DEBUG Thread_reconnect_service csmp.protocol.smf.SimpleSmfClient  qa | Local port: -1   Remote addr: abc.com:55555(smfclient 4) Closing socket
19.11.18 22:55:51.940  INFO Thread_reconnect_service mp.protocol.impl.TcpClientChannel  qa | Connecting to host 'orig=tcp://abc.com:55555, scheme=tcp://, host=abc.com, port=55555' (host 1 of 1, smfclient 4, attempt 2 of 2147483647, this_host_attempt: 1 of 2)
19.11.18 22:55:51.941 DEBUG Thread_reconnect_service ocol.impl.ChannelOpStrategyClient  qa | [JCSMPSession[testErrorHandlerUser@tcp://abc.com:55555] (0002)] Opening TcpClientChannel.
19.11.18 22:55:51.943 DEBUG Thread_reconnect_service csmp.protocol.smf.SimpleSmfClient  qa | Local port: -1   Remote addr: abc.com:55555Correlation tag not found in message, adding one: 13
19.11.18 22:55:51.944 DEBUG Thread_reconnect_service csmp.protocol.smf.SimpleSmfClient  qa | Local port: -1   Remote addr: abc.com:55555(smfclient 4) Attempting to open socket, host=abc.com, port=55555
19.11.18 22:55:51.962  INFO Thread_reconnect_service mp.protocol.impl.TcpClientChannel  qa | Connection attempt failed to host 'abc.com' ReconnectException com.solacesystems.jcsmp.JCSMPTransportException: (Client name: localhost/19108/#00560002/xnuvPhoyFH   Local port: -1   Remote addr: abc.com:55555) - Error communicating with the router. cause: java.net.UnknownHostException
19.11.18 22:55:54.964 DEBUG Thread_reconnect_service csmp.protocol.smf.SimpleSmfClient  qa | Local port: -1   Remote addr: abc.com:55555(smfclient 4) Closing socket
19.11.18 22:55:54.966  INFO Thread_reconnect_service mp.protocol.impl.TcpClientChannel  qa | Connecting to host 'orig=tcp://abc.com:55555, scheme=tcp://, host=abc.com, port=55555' (host 1 of 1, smfclient 4, attempt 2 of 2147483647, this_host_attempt: 2 of 2)
19.11.18 22:55:54.967 DEBUG Thread_reconnect_service ocol.impl.ChannelOpStrategyClient  qa | [JCSMPSession[testErrorHandlerUser@tcp://abc.com:55555] (0002)] Opening TcpClientChannel.
19.11.18 22:55:54.969 DEBUG Thread_reconnect_service csmp.protocol.smf.SimpleSmfClient  qa | Local port: -1   Remote addr: abc.com:55555Correlation tag not found in message, adding one: 14
19.11.18 22:55:54.970 DEBUG Thread_reconnect_service csmp.protocol.smf.SimpleSmfClient  qa | Local port: -1   Remote addr: abc.com:55555(smfclient 4) Attempting to open socket, host=abc.com, port=55555
19.11.18 22:55:54.972  INFO Thread_reconnect_service mp.protocol.impl.TcpClientChannel  qa | Connection attempt failed to host 'abc.com' ReconnectException com.solacesystems.jcsmp.JCSMPTransportException: (Client name: localhost/19108/#00560002/xnuvPhoyFH   Local port: -1   Remote addr: abc.com:55555) - Error communicating with the router. cause: java.net.UnknownHostException
19.11.18 22:55:57.975 DEBUG Thread_reconnect_service csmp.protocol.smf.SimpleSmfClient  qa | Local port: -1   Remote addr: abc.com:55555(smfclient 4) Closing socket
19.11.18 22:55:57.977  INFO Thread_reconnect_service mp.protocol.impl.TcpClientChannel  qa | Connecting to host 'orig=tcp://abc.com:55555, scheme=tcp://, host=abc.com, port=55555' (host 1 of 1, smfclient 4, attempt 3 of 2147483647, this_host_attempt: 1 of 2)
19.11.18 22:55:57.978 DEBUG Thread_reconnect_service ocol.impl.ChannelOpStrategyClient  qa | [JCSMPSession[testErrorHandlerUser@tcp://abc.com:55555] (0002)] Opening TcpClientChannel.
19.11.18 22:55:57.981 DEBUG Thread_reconnect_service csmp.protocol.smf.SimpleSmfClient  qa | Local port: -1   Remote addr: abc.com:55555Correlation tag not found in message, adding one: 15
19.11.18 22:55:57.982 DEBUG Thread_reconnect_service csmp.protocol.smf.SimpleSmfClient  qa | Local port: -1   Remote addr: abc.com:55555(smfclient 4) Attempting to open socket, host=abc.com, port=55555
19.11.18 22:55:57.983  INFO Thread_reconnect_service mp.protocol.impl.TcpClientChannel  qa | Connection attempt failed to host 'abc.com' ReconnectException com.solacesystems.jcsmp.JCSMPTransportException: (Client name: localhost/19108/#00560002/xnuvPhoyFH   Local port: -1   Remote addr: abc.com:55555) - Error communicating with the router. cause: java.net.UnknownHostException

Solution

  • It looks like you may have configured the connect retries property to "-1" in the connection factory on the Solace side. This will cause the application to retry indefinitely.

    In your application, you have configured appropriate reconnect setting for the JNDI connection but not for the data connection.

    The data connection reconnect properties must be set on the Solace side in the connection factory. (https://docs.solace.com/Solace-JMS-API/Data-Connection-Properti.htm)