简体   繁体   中英

Spring inbound integration on cluster mode

we are using spring inbound polling adapter to check for a file and process it. Problem is process is running multiple nodes in cluster mode. Our Test environment is using load balancing with two nodes, the requirement is to start this polling process on one node. How can we achieve this without creating two war files..? We are not supposed to use XML configuration.

For this purpose Spring Integration provides FileSystemPersistentAcceptOnceFileListFilter which you should configure with same shared external MetadataStore : http://docs.spring.io/spring-integration/reference/html/system-management-chapter.html#metadata-store

EDIT

As Gary suggested, you can control autoStartup for the Inbound Channel Adapter.

I tested it like :

@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() {

Works well.

The expression ${integrationAllowed} represent property-placeholder sentence.

If you can't use some shared persistence resource to control the cluster state, than it doesn't look like a cluster...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM