【问题标题】:How to configure Spring to take a data from socket bytestream?如何配置 Spring 从套接字字节流中获取数据?
【发布时间】:2014-04-09 05:37:18
【问题描述】:

我正在尝试在服务器端配置Spring 以打开套接字、侦听连接并获取传入流(转换为String)。

但是我找不到任何关于如何创建这样一个传入的 tcp 连接的工作示例。这就是我所拥有的(取自一个不完整的例子):

<int-ip:tcp-connection-factory id="cfServer"
    type="server"
    port="8080"
    using-nio="true"
    single-use="true" />

<int-ip:tcp-inbound-channel-adapter id="inboundServer"
    channel="loop"
    connection-factory="server"/>

<int:channel id="loop"/>

好吧,但是我该如何继续呢?我怎样才能将这些适配器绑定到支持类?这些类必须是什么样的?

【问题讨论】:

  • 嗨。您是否使用任何应该获取流的服务激活器(或任何其他消费者)?或者你无法启动任何 tcp 服务器?

标签: java spring sockets spring-integration


【解决方案1】:

订阅 loop 频道,例如&lt;service-activator/&gt;

tcp-client-server sample

【讨论】:

    猜你喜欢
    • 2016-06-28
    • 2019-07-30
    • 2020-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多