title: Handle Leader instance with Spring Boot and Consul
body: <p>I'm currently working on a spring boot application that uses Consul as a service discovery.<br>
  Our web API has multiple instances on different Docker containers and is registered successfully with Consul.<br>
  Our main issue now is to elect a leader among our instances and have an automatic re-election in case if the former leader is down.<br>
  I have read that Consul provides a Key-Value Store and has lock on those, I was thinking that we could use a key created before hand, then the first instance to read it would have the "lock". If this instance crashes, an other one would acquire the lock and would be detected as the new leader.<br>
  I have read several examples, however I've only found command lines examples, not Java/Spring boot implementations.<br></p>
  
  <p>Can anyone tell me if this idea could do the job and could anyone provide an example with Spring Boot or give me a link to a tutorial please?<br>
  I'm a total beginner with Spring Boot and Consul.</p>
  
  <p>Thanks in advance!</p>