Add Leadership Election example and configuration
This commit is contained in:
parent
d8d00f117e
commit
1441609020
@ -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));
|
||||||
|
}
|
||||||
|
}
|
@ -11,4 +11,19 @@ spring:
|
|||||||
enabled: true
|
enabled: true
|
||||||
instanceId: ${spring.application.name}:${random.value}
|
instanceId: ${spring.application.name}:${random.value}
|
||||||
server:
|
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
|
Loading…
x
Reference in New Issue
Block a user