我正在使用spring集成与侦听tcp连接的公司进行交互。 我使用TcpOutboundGateway发送消息并将ack放在回复通道上。 这非常有效。 但是,在等待第三方发送Ack时,我会定期并有时一致地获取MessageTimeoutException。在他们的日志中,他们抱怨套接字连接在发送确认之前已经关闭。它似乎很快发生,即使我已经尝试指定它们有最多10秒的时间来发送确认。
我已经设置了remotetimeout,requesttimeout,sendtimeout,soTimeout,但似乎没有什么能帮助减少出现。
我正在尝试运行多个这些网关,不要认为这是一个问题。
我不知道应该知道我应该寻找什么。
我相信这是相关的代码:
@Bean
public TcpNetClientConnectionFactory createTcpClientConnectionFactory() {
TcpNetClientConnectionFactory tcpNetClientConnectionFactory = new TcpNetClientConnectionFactory(host, port);
LisSerializer lisSerializer = new LisSerializer(maxMessageSize);
tcpNetClientConnectionFactory.setSerializer(lisSerializer);
tcpNetClientConnectionFactory.setDeserializer(lisSerializer);
tcpNetClientConnectionFactory.setSingleUse(true);
tcpNetClientConnectionFactory.setSoTimeout(tcpTimeout);
return tcpNetClientConnectionFactory;
}
@Bean
@ServiceActivator(inputChannel="tcpToLisEncoded")
public TcpOutboundGateway createTcpOutboundGateway(TcpNetClientConnectionFactory createTcpClientConnectionFactory){
TcpOutboundGateway tcpOutboundGateway = new TcpOutboundGateway();
tcpOutboundGateway.setConnectionFactory(createTcpClientConnectionFactory);
tcpOutboundGateway.setReplyChannel(tcpOutAck());
tcpOutboundGateway.setRemoteTimeout(tcpTimeout);
tcpOutboundGateway.setRequestTimeout(tcpTimeout);
tcpOutboundGateway.setSendTimeout(tcpTimeout);
tcpOutboundGateway.setRequiresReply(true);
return tcpOutboundGateway;
}
我得到错误:
018-02-22 22:56:44.969 ERROR 29 --- [SimpleAsyncTaskExecutor-1] o.s.i.ip.tcp.TcpOutboundGateway : Tcp Gateway exception
org.springframework.integration.MessageTimeoutException: Timed out waiting for response
at org.springframework.integration.ip.tcp.TcpOutboundGateway.handleRequestMessage(TcpOutboundGateway.java:146) ~[spring-integration-ip-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:109) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:89) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:425) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:375) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:360) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:271) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:188) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:115) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:89) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:425) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:375) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:150) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:45) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.AbstractMessagingTemplate.sendAndReceive(AbstractMessagingTemplate.java:42) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:97) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:38) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:79) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:70) [spring-messaging-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:449) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceive(MessagingGatewaySupport.java:422) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:478) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:433) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:424) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.integration.gateway.GatewayCompletableFutureProxyFactoryBean.invoke(GatewayCompletableFutureProxyFactoryBean.java:65) [spring-integration-core-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) [spring-aop-4.3.11.RELEASE.jar!/:4.3.11.RELEASE]
at com.sun.proxy.$Proxy120.sendMessage(Unknown Source) [na:na]