簡體   English   中英

如何發送TCP請求的回復(spring-integration)?

[英]How to send reply for TCP requests (spring-integration)?

我需要類似的東西,如無法發送UDP消息響應,但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>

在TCP的情況下,它更容易,因為您可以使用入站網關

關於此事的樣本在官方存儲庫中: https//github.com/spring-projects/spring-integration-samples/tree/master/basic/tcp-client-server

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM