SpringXD:多个模块实例的单独配置

SpringXD:多个模块实例的单独配置,spring,spring-xd,Spring,Spring Xd,我的SpringXD流定义包含对相同自定义模块的引用,但配置参数不同,例如 stream create --name mystream1 --definition "tcp --port=4444 | mycustommod --myprop='very long property value 1'" | log" stream create --name mystream2 --definition "tcp --port=5555 | mycustommod --myprop='very l

我的SpringXD流定义包含对相同自定义模块的引用,但配置参数不同,例如

stream create --name mystream1 --definition "tcp --port=4444 | mycustommod --myprop='very long property value 1'" | log"
stream create --name mystream2 --definition "tcp --port=5555 | mycustommod --myprop='very long property value 2'" | log"
我可以将长模块配置放入外部模块配置文件中。但这只适用于第一个模块实例。对于我在流定义中使用的其余模块实例,我必须直接覆盖流定义中的外部化配置

如果我有许多[或长]属性值要覆盖,那么流定义就会膨胀


是否有方法将不同的模块实例配置放到外部配置文件中,以便保持流定义清晰?

您可以在模块配置文件中定义一个属性占位符,例如

<context:property-placeholder location="${xd.module.config.location}\processor\${xd.module.name}\${xd.stream.name}.properties"
     ignore-resource-not-found="true" local-override="true"/>

然后在你的情况下,你把你的财产

<module_config_location>\processor\mycustommod\mystream1.properties
<module_config_location>\processor\mycustommod\mystream2.properties   
\processor\mycustommod\mystream1.properties
\processor\mycustommod\mystream2.properties

etc

这是一个巧妙的方法,谢谢!如果在同一个流定义中有多个模块实例,看起来我也可以使用${xd.module.index}。这里需要注意的重要副作用是:属性文件存在会覆盖(优先)流定义中明确提供的选项。