0

如何为 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" /> 

提前致谢!

4

1 回答 1

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 问题,这将使使用其中一些功能变得更容易。

要点在这里。请记住,设置本地端口是不寻常的——通常客户端选择一个临时端口。硬连线本地端口的问题是,如果它正在使用(或者TIME_WAIT自上次使用后仍然存在),它将无法绑定。

于 2013-11-06T16:04:12.003 回答