Spring 集群模式入站集成
Spring inbound integration on cluster mode
我们正在使用 spring 入站轮询适配器来检查文件并处理它。问题是进程是集群模式下的 运行 个多个节点。我们的测试环境使用两个节点的负载平衡,要求是在一个节点上启动此轮询过程。我们如何在不创建两个 war 文件的情况下实现这一目标..?我们不应该使用 XML 配置。
为此 Spring 集成提供 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}
表示属性-占位符句。
如果您不能使用一些共享持久性资源来控制集群状态,那么它看起来不像一个集群...
我们正在使用 spring 入站轮询适配器来检查文件并处理它。问题是进程是集群模式下的 运行 个多个节点。我们的测试环境使用两个节点的负载平衡,要求是在一个节点上启动此轮询过程。我们如何在不创建两个 war 文件的情况下实现这一目标..?我们不应该使用 XML 配置。
为此 Spring 集成提供 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}
表示属性-占位符句。
如果您不能使用一些共享持久性资源来控制集群状态,那么它看起来不像一个集群...