【问题标题】:Spring integration - TCP connection client side - Host/Port obtained from messageSpring集成-TCP连接客户端-从消息中获取的主机/端口
【发布时间】:2015-10-11 14:33:38
【问题描述】:

我知道这是一个类似的问题: Spring Integration. Unknown host and tcp-connection-factory

但是,在我的特定情况下,tcp 连接是基于 si 消息流建立的。我正在编写一个程序,该程序通过 tcp/ip 连接“伪造”用户登录到特定站点。主机/端口每周更改一次,因此我更喜欢动态设置连接。因此,目标服务器的那些主机/IP 不是静态的。

我仍然想知道除了 [动态 ftp 示例] 之外是否还有其他方法可以为每个 tcp/ip 连接设置一个全新的 applicationContext 并修改连接工厂,这是非常重要的工作。

我的理想情况是:

<int-ip:tcp-outbound-gateway id="outGateway"
request-channel="input"
reply-channel="clientBytes2StringChannel"
connection-factory="client"
connection-host="#{headers.dest.host}"
connection-port="#{headers.dest.port}"
request-timeout="10000"
reply-timeout="10000"/>


<int-ip:tcp-connection-factory id="client"
type="client"
host="#{headers.dest.host}"
port="#{headers.dest.port}"
single-use="true"
so-timeout="10000"/>

目标主机和端口在消息头中的位置。

我知道我的用例很少见,但它在我的特定业务逻辑中非常有用。我的整个 web 应用程序基于来自这些原始 tcp-ip 连接的消息运行。

【问题讨论】:

    标签: spring tcp spring-integration host


    【解决方案1】:

    目前不可能/不容易 - 即使您自定义或扩展 tcp-connection-factory 的类以能够连接到不断变化的主机。有一个 open new feature request in JIRA 来提供该功能。 Simillar question here.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-03
      • 1970-01-01
      • 1970-01-01
      • 2014-01-14
      • 1970-01-01
      • 1970-01-01
      • 2015-08-15
      相关资源
      最近更新 更多