【问题标题】:How can I set default outgoing port and listening port on spring integration?如何在 spring 集成中设置默认传出端口和侦听端口?
【发布时间】:2013-11-06 15:24:07
【问题描述】:

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

提前致谢!

【问题讨论】:

    标签: java spring spring-integration


    【解决方案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 中),它将无法绑定。

    【讨论】:

    • 对不起,如果我在解释问题时犯了错误。我的意思是,从我的计算机设置一个默认的传出端口,发布的端口是带有主机 ip 的服务器端口。
    • 谢谢!!!为了不打扰您,我正在寻找您提供给我的数据的解决方案!但是您的帮助来得更快!我会试试!再次感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-08
    • 1970-01-01
    相关资源
    最近更新 更多