我有一个简单的TcpOutboundGateway通过注释配置,具有以下配置:
@Bean
@ServiceActivator(inputChannel="toTcpChannel")
public TcpOutboundGateway outboundClient() {
TcpOutboundGateway tcpOutboundGateway = new TcpOutboundGateway();
tcpOutboundGateway.setConnectionFactory(clientFactory());
tcpOutboundGateway.setRequiresReply(true);
tcpOutboundGateway.setReplyChannel(filterChannelInput());
tcpOutboundGateway.setRequestTimeout(tcpRequestTimeout);
tcpOutboundGateway.setRemoteTimeout(tcpReplyTimeout);
return tcpOutboundGateway;
}
@Bean
public AbstractClientConnectionFactory clientFactory() {
TcpNetClientConnectionFactory factory = new TcpNetClientConnectionFactory(tcpHost, Integer.parseInt(tcpPort));
factory.setSoKeepAlive(true);
factory.setSoReceiveBufferSize(tcpBufferSizeReal);
factory.setSoSendBufferSize(tcpBufferSizeReal);
factory.setSerializer(serializer());
factory.setDeserializer(serializer());
factory.setSingleUse(false);
return factory;
}
设置factory.setSingleUse(false);
我在连接中检测到以下随机问题:
13:02:10,851 WARN [org.springframework.integration.ip.tcp.connection.TcpMessageMapper] (pool-6-thread-1) Null payload from connection XXXX.XXXX.XXXX.XXXX:9100:52940:22539566-1e50-4f68-a599-0b211ab3c6ef
13:02:10,851 WARN [org.springframework.integration.ip.tcp.connection.TcpMessageMapper] (pool-6-thread-1) Null payload from connection XXXX.XXXX.XXXX.XXXX:9100:52940:22539566-1e50-4f68-a599-0b211ab3c6ef
13:02:10,851 WARN [org.springframework.integration.ip.tcp.connection.TcpMessageMapper] (pool-6-thread-1) Null payload from connection XXXX.XXXX.XXXX.XXXX:9100:52940:22539566-1e50-4f68-a599-0b211ab3c6ef
13:02:10,851 WARN [org.springframework.integration.ip.tcp.connection.TcpMessageMapper] (pool-6-thread-1) Null payload from connection XXXX.XXXX.XXXX.XXXX:9100:52940:22539566-1e50-4f68-a599-0b211ab3c6ef
.....
[Stackoverflow exception in JBOSS]
好的,我更改factory.setSingleUse(true);
以关闭每个连接的套接字,显然将日志级别设置为ERROR
,但我不明白这个问题。是什么原因? ¿无效的消息结束? ¿串行?
此外,如果套接字收到空消息但是在最后收到的消息(格式正确)之后没有消息,我使用Wireshark进行了测试。
¿有什么建议吗?
答案 0 :(得分:0)
您需要展示您的serializer()
bean。
这意味着您的deserialize()
方法返回null
被忽略(并记录)。
如果反序列化器检测到消息之间的套接字关闭,它应抛出一个SoftEndOfStreamException
,这是一个信号到框架我们完成从这个套接字接收消息。