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.
1 Answers
0
votes
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...