春季整合.未知主机和TCP连接工厂 [英] Spring Integration. Unknown host and tcp-connection-factory

查看:86
本文介绍了春季整合.未知主机和TCP连接工厂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring Integration实现TCP客户端. 要求是: 1.通过UDP连接(从某处)接收TCP服务器的IP或主机地址. 2.打开与服务器的TCP连接,从上一步打开与目标主机的TCP连接,然后将一些业务数据发送到该服务器.

I'm implementing the TCP client using the Spring Integration. The requirements are: 1. Through the UDP connection (from somewhere) receive the ip or host address of the TCP server. 2. Open TCP connection to the server, to the destination host from previous step and send some business data to this server.

我使用的是Spring Integration框架,版本为"2.2.0.RELEASE",问题是在 tcp-connection-factory 的默认配置中,主机 >属性应在xml中进行硬编码".例如:

I use the Spring Integration framework, version "2.2.0.RELEASE", and the problem is that in the default configuration of the tcp-connection-factory the host attribute should be "hardcoded" in xml. For example:

<ip:tcp-connection-factory id="client" type="client" host="localhost" port="1234" single-use="true"/>

问题是如何避免在应用程序上下文中对目标主机进行 static 定义,并能够在目标主机已知时懒惰"初始化tcp-connection-factory.

The question is how to avoid the static definition of the destination host in application context, and be able to 'lazy' initialise the tcp-connection-factory when the destination host will be known.

我知道可以通过Java的标准网络API轻松实现此流程,问题是关于Spring-Integration API的

I know that this flow could be easily implemented by the standard Network APIs of Java, and the question is specific about the Spring-Integration API

推荐答案

当前不可能/不容易-即使您为tcp-connection-factory自定义或扩展了该类以能够连接到更改的主机.在JIRA中有一个打开新功能请求,以提供此功能.

It's not currently possible/easy - even if you customize or extend the class for tcp-connection-factory to be able to connect to changing hosts. There is an open new feature request in JIRA to provide this functionality.

这篇关于春季整合.未知主机和TCP连接工厂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆