fabric8io/fabric8 — pull request #1956 by hekonsek (2014-07-08 08:15:06+00:00)
Title: [Spring Boot] Created basic version of the process registry API

Hi,

Currently exchanging information between Spring Boot microservices (in particular, and between any Java-container based microservices in general) is at least PITA :) . Microservices are usually exposes via REST and use HTTP calls to communicate between each others. It means that you need to manually maintain the `host:port` location of all services in each service. This is devOps nightmare. It also makes testing your application pretty difficult.

To address these issues I created a basic version of the *Process registry API*. This is simple key/value resolving API that can be used by Java containers to easily share properties. The current API version provides system properties and classpath based implementations of the registry - particularly useful for simple deployments and easy integration testing. I'm gonna commit ZooKeeper-based implementation soon, so we could resolve nodes addresses from the Fabric8 ZooKeeper registry.

I also created some Spring Boot goodies for the process registry, so communicating between microservices in Spring Boot is as simple as:

@Value("${services.invoicing.url}")
String invoicingServiceUrl;
...
Invoice invoice = restTemplate.getForObject(invoicingServiceUrl + "/1", Invoice.class);

Yay! So transparent! ;) Our Spring Boot integration is smart enough to try to resolve `${services.invoicing.url}` from our processing registry API before falling back to the standard file-based Spring properties. For integration/production environments `${services.invoicing.url}` might be resolved from the Fabric8 ZooKeeper registry, while for testing it will be resolved from the META-INF classpath file (or even better, from the MockHttpServer-based testing API I'm working on ;).

I tried to make process registry API generic, so we could easily extract it from the Spring Boot namespace in the future and use it with the other Java-containers (like DropWizard or Vert.x).

Feedback will be highly appreciated.

Cheers.