- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在 Spring Integration 中,我使用了几个 channel 适配器来从服务器套接字发送/接收消息。我总是使用以下适配器创建客户端连接:
@Bean
public TcpReceivingChannelAdapter tcpIn(AbstractClientConnectionFactory connectionFactory) throws Exception {
TcpReceivingChannelAdapter receiver = new TcpReceivingChannelAdapter();
receiver.setOutputChannel(fromTcp ());
receiver.setConnectionFactory(connectionFactory);
return receiver;
}
@Bean
@ServiceActivator(inputChannel = "toTcp")
public TcpSendingMessageHandler tcpOut(AbstractClientConnectionFactory connectionFactory) throws Exception {
TcpSendingMessageHandler sender = new TcpSendingMessageHandler();
sender.setConnectionFactory(connectionFactory);
sender.setClientMode(true);
return sender;
}
这里的问题是服务器在同一个套接字中应答远程端口(我打开的套接字端口)。例如,如果我将套接字连接到 127.0.0.1:4444,服务器将响应我打开的端口(使用套接字 tcp 动态)6873 而不是 4444。它使用相同的套接字。
一个快速的答案可能是使用 TcpOutboundGateway
但我在这种情况下有几个问题:
for high-volume messages, consider using a collaborating pair of channel adapters. However, you will need to provide collaboration logic.
在大容量场景中,我应该将哪个组件用于请求/响应套接字?
最佳答案
只需阅读 Reference Manual从的话:
To achieve high-volume throughput (avoiding the pitfalls of using gateways as mentioned above) you may consider configuring a pair of collaborating outbound and inbound channel adapters.
另请查看 TCP 多路复用 Sample :
This sample demonstrates how to configure collaborating channel adapters, on both the client and server sides, and one technique for correlating the responses to the corresponding request.
关于spring - TcpSendingMessageHandler 与 TcpReceivingChannelAdapter 协作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39872101/
在 Spring Integration 中,我使用了几个 channel 适配器来从服务器套接字发送/接收消息。我总是使用以下适配器创建客户端连接: @Bean public TcpReceivin
我是一名优秀的程序员,十分优秀!