我们正在使用 spring 入站轮询适配器来检查文件并处理它。问题是进程正在集群模式下运行多个节点。我们的测试环境使用两个节点的负载平衡,要求是在一个节点上启动此轮询过程。我们怎样才能在不创建两个 war 文件的情况下实现这一目标......?我们不应该使用 XML 配置。
为此 Spring Integration 提供了FileSystemPersistentAcceptOnceFileListFilter
您应该使用相同的共享外部配置MetadataStore
: http://docs.spring.io/spring-integration/reference/html/system-management-chapter.html#metadata-store http://docs.spring.io/spring-integration/reference/html/system-management-chapter.html#metadata-store
EDIT
正如加里建议的,你可以控制autoStartup
对于入站通道适配器。
我测试它是这样的:
@BeforeClass
public static void setup() {
System.setProperty("integrationAllowed", "false");
}
...
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
@Bean
@InboundChannelAdapter(value = "flow1.input", autoStartup = "${integrationAllowed}", poller = @Poller(fixedRate = "100"))
public MessageSource<?> integerMessageSource() {
效果很好。
表达方式${integrationAllowed}
代表属性占位符句子。
如果您无法使用某些共享持久性资源来控制集群状态,那么它看起来就不像集群......
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)