【问题标题】:How to send reply for TCP requests (spring-integration)?如何发送对 TCP 请求的回复(弹簧集成)?
【发布时间】:2017-10-09 18:21:28
【问题描述】:

我需要类似Can not send response for UDP message 的东西 但对于 TCP。所以客户端发送消息和TCP服务器可以像OK一样发回响应。 TCP socket-expression="@inbound.socket" 和destination-expression="headers['ip_packetAddress']" 不能使用。

这就是我的配置现在的样子:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
    xmlns:int-event="http://www.springframework.org/schema/integration/ip"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">

  <int:channel id="tcpSend"/>

  <int-ip:tcp-connection-factory id="client" type="client"/>

  <int-ip:tcp-connection-factory id="server" type="server" host="localhost" port="1234"/>

  <int-ip:tcp-outbound-channel-adapter id="tcpOutbound" channel="tcpSend"
                                   connection-factory="client"/>

  <int-ip:tcp-inbound-channel-adapter id="tcpInbound" channel="tcpReceive"
                                  connection-factory="server"/>

  <int:service-activator id="tcpHandler" input-channel="tcpReceive" output-channel="tcpSend"
                         ref="listener"/>
</beans>

【问题讨论】:

    标签: java spring sockets tcp spring-integration


    【解决方案1】:

    如果使用 TCP,则更容易,因为您可以使用 Inbound Gateway。

    关于此事的样本在官方仓库中:https://github.com/spring-projects/spring-integration-samples/tree/master/basic/tcp-client-server

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-08
      • 1970-01-01
      相关资源
      最近更新 更多