【发布时间】:2017-10-05 10:45:24
【问题描述】:
我有一个 tcp 客户端-服务器应用程序,其中客户端打开一个供一次性使用的连接,并在配置时间后断开连接。如何配置它始终保持连接处于活动状态,在关闭的连接上重新连接并确保多个客户端连接对服务器开放。
客户端配置:
<int-ip:tcp-connection-factory id="client"
type="client"
host="${server.TCP.host}"
port="${server.TCP.port}"
single-use="true"
so-timeout="${client.TCP.socketTimeOut}" />
<int-ip:tcp-outbound-gateway id="outGateway"
request-channel="bytesOut"
reply-channel="bytesIn"
connection-factory="client"
request-timeout="${client.TCP.requestTimeOut}"
reply-timeout="${client.TCP.replyTimeout}" />
服务器配置:
<int-ip:tcp-connection-factory id="tcpServerConnFactory"
type="server"
port="${service.tcp.port}"
using-nio="true"
single-use="false"
so-timeout="${service.tcp.socketTimeout}"
task-executor="taskExecutor"/>
<int-ip:tcp-inbound-gateway
id="tcpInboundGateway"
connection-factory="tcpServerConnFactory"
request-channel="bytesInChannel"
reply-channel="bytesOutChannel"
error-channel="errorChannel" />
【问题讨论】: