Consul is a system for discovering and configuring services in your infrastructure. It was built by Hashicorp, the same smart folks that created Vagrant and Packer. Consul provides services such as Service Discovery, Health Checking, Key/Value Store all while supporting multiple datacenters out of the box.

Spring Cloud Consul aims to bring all of those features to the Spring Cloud ecosystem. The project has reached its first milestone and fresh jars are available in the repo.spring.io repository. Spring Cloud Consul provides the following features:

Spring Cloud Consul Discovery: An implementation of the Spring Cloud Commons DiscoveryClient . Service registration and discovery are performed via the Consul HTTP API.

Spring Cloud Consul Config: Distributed configuration via the Consul Key/Value API. This behaves similarly to the Spring Cloud Config Client, but is backed by the distributed Consul KV Store.

Spring Cloud Consul Bus: An event bus for linking services and service instances together with distributed messaging. Useful for propagating state changes across a cluster (e.g. config change events). This is implemented using the Consul Event API.

Spring Cloud Consul UI: An embedded version of the Consul Web UI.

All of the above have the 1.0.0.M1 release tag, to get started include the following artifacts in your pom.xml :

<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-consul-config</artifactId> <version>1.0.0.M1</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-consul-discovery</artifactId> <version>1.0.0.M1</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-consul-bus</artifactId> <version>1.0.0.M1</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-consul-ui</artifactId> <version>1.0.0.M1</version> </dependency>

Follow the documentation to make sure Consul is installed and running.

A sample application that might look like the following:

@SpringBootApplication @EnableDiscoveryClient @EnableConsulUi @RestController public class SampleApp2 { @RequestMapping("/") public String hello() { return "Hello World"; } public static void main(String[] args) { SpringApplication.run(SampleApplication.class, args); } }

After running your app, hit http://localhost:8080/ui to see the consul ui.

The code is hosted on github, and community contributions are extremely welcome, so get on over there are check it out. There is a sample in spring-cloud-consul-sample. Instructions to run the sample are included in the README.

SpringOne 2GX 2015 is around the corner!

Book your place at SpringOne2GX in Washington, DC soon. Super Early Bird Price expires June 12th! It’s simply the best opportunity to find out first hand all that’s going on and to provide direct feedback. I’ll be speaking about Spring Cloud Consul, watch here for future details. Check recent blog posts to see what I mean and there is more to come!

Discounts