Spring Integration-IP-收到多个响应

问题描述

我正在使用Spring Integration tcp进行大批量集成,我只发送一个请求并通过一个连接接收超过数百万个数据,而两次接收消息之间的时间小于100毫秒。

这是我的上下文xml,我正在使用TCPOutboundGateway。

soup = BeautifulSoup(result.text,'html.parser')

#Return
{"success": false,"site_id":"" }

我以github为例。 我的问题是;我可以成功处理和处理第一个收到的消息。但是其余的都没有例外。

<?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>

我阅读了TcpOutboundGateway的源代码,还阅读了缓存客户端连接工厂文档,但找不到实现解决方案的正确方法

解决方法

该网关不是针对该场景而设计的,每个请求仅支持1条回复。

在这种情况下,您可以使用一对出站/入站通道适配器而不是网关。

即将发布的5.4版本具有enhancement to the gateway to support this scenario

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...