Files
Dave Syer 4f4d90376c Migrate etcd features from Spring Cloud
Update etcd to use etcd-java which supports v3 API

Fix docs

Address PR comments

Remove unused import

Polishing code style.
2018-10-15 17:54:26 -04:00

849 B

SPRING INTEGRATION ETCD SUPPORT

ETCD LEADER ELECTION

If you need to elect a leader (e.g. for highly available message consumer where only one node should receive messages) you just need to create a LeaderInitiator. Example:

@Bean
public EtcdClient etcdClient() {
	return EtcdClient.forEndpoint("localhost",2379).withPlainText().build();
}

@Bean
public LeaderInitiator initiator() {
	LeaderInitiator initiator = new LeaderInitiator(etcdClient());
	return initiator;
}

Then when a node is elected leader it will send OnGrantedEvent to all application listeners. See the Spring Integration User Guide for more information on how to use those events to control messaging endpoints.