title: Using Spring Cloud to implement a Global Lock
body: <p>I have a requirement to implement a sequence generating service such that it runs multiple instances of this service in n number of data centers (vm or baremetal machines). The following are the rules for the service regardless of which instance of the service is called (from any of the data centers):</p>
  
  <ul>
  <li>All sequences must be unique </li>
  <li>A sequence number cannot be skipped (i.e. cannot generate 2 before 1, etc)</li>
  <li>If an instance of the service goes down (or a complete data center) the others must be able to handle requests and conform to the previous 2 rules.</li>
  <li>Must be able to serve up at least 200,000 sequences per day. </li>
  </ul>
  
  <p>I've thought about a lot of different solutions, but basically it comes down to some sort of distributed service locking. Spring cloud claims to have some sort of "global lock", however, I don't see any real description or implementation example. I am open to any other solution (except Apache Zookeeper). </p>
  
  <p>I toyed with the idea of running each service behind RabbitMQ and letting each service notify the others when one is running, but that doesn't seem very efficient. </p>