Add Leadership Election example and configuration

This commit is contained in:
Cavero Barca 2020-07-23 17:04:30 +02:00
parent d8d00f117e
commit 1441609020
2 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,16 @@
package com.baeldung.spring.cloud.consul.leadership;
import java.util.concurrent.ExecutionException;
import net.kinguin.leadership.consul.factory.SimpleConsulClusterFactory;
public class LeadershipElection {
public static void main(String[] args) throws ExecutionException, InterruptedException {
new SimpleConsulClusterFactory()
.mode(SimpleConsulClusterFactory.MODE_MULTI)
.debug(true)
.build()
.asObservable()
.subscribe(i -> System.out.println(i));
}
}

View File

@ -11,4 +11,19 @@ spring:
enabled: true
instanceId: ${spring.application.name}:${random.value}
server:
port: 0
port: 0
cluster:
leader:
serviceName: cluster
serviceId: node-1
consul:
host: localhost
port: 8500
discovery:
enabled: false
session:
ttl: 15
refresh: 7
election:
envelopeTemplate: services/%s/leader