【问题标题】:TCP socket server to handle multiple clients connections concurrently using spring integration使用 Spring 集成同时处理多个客户端连接的 TCP 套接字服务器
【发布时间】:2018-03-29 14:12:07
【问题描述】:

我一直致力于使用 spring 集成创建 TCP 套接字服务器,参考来自 post 我能够设置套接字连接。

我的要求有 4 个客户端与服务器建立套接字连接。 如何处理来自所有 4 个客户端的并发请求。必须在 TcpReceivingChannelAdapter 上进行哪些更改。

谁能帮帮我。

【问题讨论】:

    标签: sockets spring-boot spring-integration


    【解决方案1】:

    这种担忧并不明确。 TcpNetServerConnectionFactory(任何AbstractConnectionFactory)使用Executor 来分配来自已建立连接的工作。默认情况下是这样的:

    if (this.taskExecutor == null) {
        this.privateExecutor = true;
        this.taskExecutor = Executors.newCachedThreadPool();
    }
    

    所以,这告诉我们,实际上所有 4 个客户端都将在服务器上同时处理。

    【讨论】:

    • 我关心的是同时处理多个客户端连接。所以根据你的 cmets,默认情况下 TcpNetServerConnectionFactory 处理并发连接而不需要实现执行器服务?
    • 正确。您始终可以将任何其他 TaskExecutor 注入到 ConnectionFactory
    • 感谢您的回答。不胜感激!
    猜你喜欢
    • 1970-01-01
    • 2018-12-14
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    • 2014-08-18
    • 1970-01-01
    • 2018-04-28
    相关资源
    最近更新 更多