-
Notifications
You must be signed in to change notification settings - Fork 7
spring integration leader starter
Patrick D edited this page Sep 23, 2018
·
28 revisions
Use a spring-boot autoconfiguration aware module such as the following:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-zookeeper-core</artifactId>
</dependency>
... or manually define a bean that creates the CuratorFramework
:
@Configuration
public class MyZookeeperConfiguration {
@Bean
CuratorFrameworkFactoryBean curatorFramework() {
return new CuratorFrameworkFactoryBean("localhost:2181");
}
}
You can define that some of your integration endpoints become "leader-aware" by declaring their endpoint bean name in your spring configuration file.
Example:
@Configuration
public class FlowExampleConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(FlowExampleConfig.class);
private static final String POLLER_BEAN_NAME = "sample-polling-endpoint";
@Bean
IntegrationFlow sampleIntegrationFlow() {
return IntegrationFlows
.from(() -> UUID.randomUUID().toString(), c -> c
.id(POLLER_BEAN_NAME)
.poller(p -> p.fixedDelay(1000))
.autoStartup(true))
.handle((GenericHandler<String>) (payload, headers) -> {
LOGGER.info("Handle Message: {}", payload);
return null;
})
.get();
}
}
In your application.[yml|property]
define the endpoint-bean-id as
spring-integration:
leader-aware:
endpoints: sample-polling-endpoint