Spring 集成 - IP - 接收多个响应
Spring Integration - IP - Receiving more than one response
我正在使用 spring 集成 tcp 进行大量集成,我只发送一个请求并通过一个连接接收超过数百万的数据,并且两次接收消息之间的时间低于 100毫秒。
这是我的上下文 xml,我正在使用 TCPOutboundGateway。
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/ip https://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
<bean class="org.springframework.integration.samples.tcpclientserver.EchoService"
id="echoService"/>
<bean class="org.springframework.integration.samples.tcpclientserver.ByteArrayToStringConverter"
id="javaDeserializer"/>
<int-ip:tcp-connection-factory
apply-sequence="true" deserializer="javaDeserializer"
host="127.0.0.1"
id="TCPClientFactory1"
port="443"
single-use="false"
type="client"
/>
<int-ip:tcp-outbound-gateway
async="true" close-stream-after-send="false" connection-factory="TCPClientFactory1"
id="outGateway"
remote-timeout="10000"
reply-channel="serverBytes2StringChannel"
reply-timeout="10000"
request-channel="input"
request-timeout="10"
/>
<int:channel id="input"/>
<int:channel id="toSA"/>
<int:gateway default-request-channel="input"
id="gw"
service-interface="org.springframework.integration.samples.tcpclientserver.SimpleGateway"/>
<int:object-to-string-transformer auto-startup="true" id="serverBytes2String"
input-channel="serverBytes2StringChannel"
output-channel="toSA"/>
<int:service-activator
input-channel="toSA"
method="test"
ref="echoService"
/>
<int:transformer expression="payload.failedMessage.payload + ':' + payload.cause.message"
id="errorHandler"
input-channel="errorChannel"/>
</beans>
我从github中举了一个例子。
我的问题是;我可以成功处理和处理第一条收到的消息。但其余的都低于例外。
20:21:34.550 [pool-1-thread-1] ERROR org.springframework.integration.ip.tcp.TcpOutboundGateway - Cannot correlate response - no pending reply for 127.0.0.1:443:57385:e164052f-64e5-4d41-9d46-4a12bad12cd4
我阅读了TcpOutboundGateway的源代码,也阅读了缓存客户端连接工厂文档,但没有找到合适的解决方法。
网关不是为那种情况设计的,它只支持每个请求 1 个回复。
对于这种情况,您可以使用一对 outbound/inbound 通道适配器,而不是网关。
即将发布的 5.4 版本 enhancement to the gateway to support this scenario。
我正在使用 spring 集成 tcp 进行大量集成,我只发送一个请求并通过一个连接接收超过数百万的数据,并且两次接收消息之间的时间低于 100毫秒。
这是我的上下文 xml,我正在使用 TCPOutboundGateway。
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/ip https://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
<bean class="org.springframework.integration.samples.tcpclientserver.EchoService"
id="echoService"/>
<bean class="org.springframework.integration.samples.tcpclientserver.ByteArrayToStringConverter"
id="javaDeserializer"/>
<int-ip:tcp-connection-factory
apply-sequence="true" deserializer="javaDeserializer"
host="127.0.0.1"
id="TCPClientFactory1"
port="443"
single-use="false"
type="client"
/>
<int-ip:tcp-outbound-gateway
async="true" close-stream-after-send="false" connection-factory="TCPClientFactory1"
id="outGateway"
remote-timeout="10000"
reply-channel="serverBytes2StringChannel"
reply-timeout="10000"
request-channel="input"
request-timeout="10"
/>
<int:channel id="input"/>
<int:channel id="toSA"/>
<int:gateway default-request-channel="input"
id="gw"
service-interface="org.springframework.integration.samples.tcpclientserver.SimpleGateway"/>
<int:object-to-string-transformer auto-startup="true" id="serverBytes2String"
input-channel="serverBytes2StringChannel"
output-channel="toSA"/>
<int:service-activator
input-channel="toSA"
method="test"
ref="echoService"
/>
<int:transformer expression="payload.failedMessage.payload + ':' + payload.cause.message"
id="errorHandler"
input-channel="errorChannel"/>
</beans>
我从github中举了一个例子。 我的问题是;我可以成功处理和处理第一条收到的消息。但其余的都低于例外。
20:21:34.550 [pool-1-thread-1] ERROR org.springframework.integration.ip.tcp.TcpOutboundGateway - Cannot correlate response - no pending reply for 127.0.0.1:443:57385:e164052f-64e5-4d41-9d46-4a12bad12cd4
我阅读了TcpOutboundGateway的源代码,也阅读了缓存客户端连接工厂文档,但没有找到合适的解决方法。
网关不是为那种情况设计的,它只支持每个请求 1 个回复。
对于这种情况,您可以使用一对 outbound/inbound 通道适配器,而不是网关。
即将发布的 5.4 版本 enhancement to the gateway to support this scenario。