I have question about timeout in JmsOutboundGateway for connection (org.springframework.integration.jms.JmsOutboundGateway$GatewayReplyListenerContainer refreshConnectionUntilSuccessful) - in my case mq connection. When mq manager is down JmsOutboundGateway tries to connect to mq for some time and then release thread/request.
Where I can set or even check this timeout in JmsOutboundGateway? Is it taken from ConnectionFactory?
Why there is value unlimited for FixedBackOff but request will reach timeout.
Error log:
org.springframework.integration.jms.JmsOutboundGateway$GatewayReplyListenerContainer refreshConnectionUntilSuccessful.1007]
Could not refresh JMS Connection for destination - retrying using FixedBackOff{interval=5000, currentAttempts=4, maxAttempts=unlimited}.
....reason '2538' ('MQRC_HOST_NOT_AVAILABLE').
----UPDATE-------
Full error log:
org.springframework.integration.jms.JmsOutboundGateway$GatewayReplyListenerContainer handleListenerSetupFailure.940 ] - Setup of JMS message listener invoker failed for destination '' - trying to recover. Cause: null
org.springframework.integration.jms.JmsOutboundGateway$GatewayReplyListenerContainer refreshConnectionUntilSuccessful.1007 ] - Could not refresh JMS Connection for destination '' - retrying using FixedBackOff{interval=5000, currentAttempts=2, maxAttempts=unlimited}. Cause: JMSWMQ0018: Failed to connect to queue manager 'LOCAL' with connection mode 'Client' and host name 'localhost(1415)'.; nested exception is com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2538' ('MQRC_HOST_NOT_AVAILABLE').
org.springframework.integration.jms.JmsOutboundGateway$GatewayReplyListenerContainer refreshConnectionUntilSuccessful.1007 ] - Could not refresh JMS Connection for destination '' - retrying using FixedBackOff{interval=5000, currentAttempts=3, maxAttempts=unlimited}. Cause: JMSWMQ0018: Failed to connect to queue manager 'LOCAL' with connection mode 'Client' and host name 'localhost(1415)'.; nested exception is com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2538' ('MQRC_HOST_NOT_AVAILABLE').
org.springframework.integration.dispatcher.UnicastingDispatcher logExceptionBeforeFailOver.185 ] - An exception was thrown by 'bean 'jmsOutbound...Gateway'; defined in: 'class path resource [/endpoints/GatewayConfig.class]'; from source: '.endpoints....jmsOutbound...Gateway(org.springframework.jms.connection.CachingConnectionFactory,org.springframework.integration.jms.JmsOutboundGateway$ReplyContainerProperties)'' while handling 'GenericMessage [payload= dummy message, headers={Persistence=0, replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@20e63967, Format=MQSTR , errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@20e63967, Priority=4, messageId=[B@4569ec95, id=016d2bb2-9b03-aad8-2dd1-13cb92e6c42e, uuid=bf90a819-5430-49f8-8dd3-a23eb87e515f, timestamp=1710398153261}]': failed to handle a message in the [bean 'jmsOutboundGateway'; defined in: 'class path resource [.../endpoints/GatewayConfig.class]'; from source: 'com....configuration.endpoints.GatewayConfig.jmsOutbound...Gateway(org.springframework.jms.connection.CachingConnectionFactory,org.springframework.integration.jms.JmsOutboundGateway$ReplyContainerProperties)']; nested exception is com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'LOCAL' with connection mode 'Client' and host name 'localhost(1415)'.
Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.. Failing over to the next subscriber.
Code :
@MessagingGateway(name = "LocalGateway")
public interface LocalGateway {
@Gateway(requestChannel = "inputLocalChannel")
ListenableFuture<Message<String>> sendMsg(Message<String> request);
}
@Bean
public MessageChannel inputLocalChannel(AsyncTaskExecutor gatewayReqExecutor) {
return new ExecutorChannel(gatewayReqExecutor);
}
@Bean
@ServiceActivator(inputChannel = "inputLocalChannel")
public JmsOutboundGateway firstHandler(){
// some code
}
@Bean
@ServiceActivator(inputChannel = "inputLocalChannel")
public JmsOutboundGateway secondHandler(){
// some code
}
That is expected behavior. The BackOff
is there for a listener container, but JmsOutboundGateway
is activated by an external call, therefore it is OK that it fails after some timeout. It is not OK to block the requestor infinitely.
You can think about a RequestHandlerRetryAdvice
applied for this gateway, but again: it is better to think about some logic to deal with those lost connections in your application instead of trying to wait for a long time.