如何在spring集成中设置默认传出端口和侦听端口?

时间:2013-11-06 15:24:07

标签: java spring spring-integration

如何为spring集成的回复设置默认传出端口和侦听端口? 可能吗? 我想用tcp技术做到这一点。

这是我的代码:

<int-ip:tcp-connection-factory id="client"
    type="client" host="${netSocketServer}" port="${netPort}"
    single-use="true" so-timeout="${netSoTimeOut}" />

<int:channel id="input" />

<int-ip:tcp-outbound-gateway id="outGateway"
    request-channel="input" reply-channel="reply" connection-factory="client"
    request-timeout="${netRequestTimeout}" reply-timeout="${netReplyTimeout}" />


<int:channel id="reply" datatype="java.lang.String" /> 

提前致谢!

1 个答案:

答案 0 :(得分:1)

占位符支持默认值,包括:1234部分...

<int-ip:tcp-connection-factory id="client"
    type="client" host="${netSocketServer}" port="${netPort:1234}"
    single-use="true" so-timeout="${netSoTimeOut}" />

编辑:根据以下评论......

该框架目前不支持此开箱即用;您需要向连接工厂提供自定义TcpSocketFactorySupport(通过socket-factory-support属性)以使用备用连接策略(允许您设置本地端口)。如果您需要帮助,我可能会在第二天左右发布一条要点。

我将很快开始使用JIRA Issue,这样可以更轻松地使用其中一些功能。

Gist here。请记住,设置本地端口是不常见的 - 通常客户端选择一个短暂的端口。硬连接本地端口的问题是,如果它正在使用它将无法绑定(或者自上次使用以来仍然在TIME_WAIT中)。

相关问题