如何在 TCP 出站适配器中设置 SO_REUSEADDR?
How to set SO_REUSEADDR in a TCP Outbound Adapter?
我有几个 TCP/IP 出站适配器可以将消息发送到连接的客户端。 TCP/IP 通信协议要求设置套接字标志:TCP_NODELAY、SO_REUSEADDR 和 SO_KEEPALIVE.
@Override
public void start(String context, int port) {
TcpServerConnectionFactorySpec server = Tcp.netServer(port)
.id(context)
.soTcpNoDelay(true)
.soKeepAlive(true)
.serializer(new ByteArrayLengthHeaderSerializer())
;
IntegrationFlow flow = f -> f.handle(Tcp.outboundAdapter(server));
this.registrations.put(context, flowContext.registration(flow).register());
}
如何将套接字的 SO_REUSEADDR 标志设置为 TRUE?
实施自定义 TcpSocketSupport
...
public class MySocketSupport extends DefaultTcpSocketSupport {
@Override
public void postProcessServerSocket(ServerSocket serverSocket) {
...
}
}
然后...
.tcpSocketSupport(new MySocketSupport())
我有几个 TCP/IP 出站适配器可以将消息发送到连接的客户端。 TCP/IP 通信协议要求设置套接字标志:TCP_NODELAY、SO_REUSEADDR 和 SO_KEEPALIVE.
@Override
public void start(String context, int port) {
TcpServerConnectionFactorySpec server = Tcp.netServer(port)
.id(context)
.soTcpNoDelay(true)
.soKeepAlive(true)
.serializer(new ByteArrayLengthHeaderSerializer())
;
IntegrationFlow flow = f -> f.handle(Tcp.outboundAdapter(server));
this.registrations.put(context, flowContext.registration(flow).register());
}
如何将套接字的 SO_REUSEADDR 标志设置为 TRUE?
实施自定义 TcpSocketSupport
...
public class MySocketSupport extends DefaultTcpSocketSupport {
@Override
public void postProcessServerSocket(ServerSocket serverSocket) {
...
}
}
然后...
.tcpSocketSupport(new MySocketSupport())