【发布时间】:2017-04-01 10:30:48
【问题描述】:
我们正在使用 spring 入站轮询适配器来检查文件并对其进行处理。问题是进程在集群模式下运行多个节点。我们的测试环境使用两个节点的负载平衡,要求是在一个节点上启动这个轮询过程。我们如何在不创建两个战争文件的情况下实现这一点..?我们不应该使用 XML 配置。
【问题讨论】:
标签: spring spring-integration load-balancing
我们正在使用 spring 入站轮询适配器来检查文件并对其进行处理。问题是进程在集群模式下运行多个节点。我们的测试环境使用两个节点的负载平衡,要求是在一个节点上启动这个轮询过程。我们如何在不创建两个战争文件的情况下实现这一点..?我们不应该使用 XML 配置。
【问题讨论】:
标签: spring spring-integration load-balancing
为此,Spring Integration 提供了FileSystemPersistentAcceptOnceFileListFilter,您应该使用相同的共享外部MetadataStore 进行配置:http://docs.spring.io/spring-integration/reference/html/system-management-chapter.html#metadata-store
编辑
按照 Gary 的建议,您可以控制入站通道适配器的 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}表示属性占位符语句。
如果你不能使用一些共享持久性资源来控制集群状态,那么它看起来就不像一个集群......
【讨论】:
autoStartup = "${integrationAllowed}"