Spencer Gibb
twitter: @spencerbgibb
email: sgibb@pivotal.io
Dave Syer
twitter: @david_syer
email: dsyer@pivotal.io
(Spring Boot and Netflix OSS
or Spring Cloud Components)
http://www.slideshare.net/ewolff/micro-services-small-is-beautiful
http://martinfowler.com/articles/microservices.html
http://davidmorgantini.blogspot.com/2013/08/micro-services-what-are-micro-services.html

It needs to be super easy to implement and update a service:
@RestController
class ThisWillActuallyRun {
@RequestMapping("/")
String home() {
"Hello World!"
}
}
and you don't get much more "micro" than that.
Deploying services needs to be simple and reproducible
$ cf push app.groovy
and you don't get much more convenient than that.
(Same argument for other PaaS solutions)
Book (Humble and Farley): http://continuousdelivery.com Netflix Blog: http://techblog.netflix.com/2013/08/deploying-netflix-api.html
It's excellent to be able to implement a microservice really easily (Spring Boot), but building a system that way surfaces "non-functional" requirements that you otherwise didn't have.
There are laws of physics that make some problems unsolvable (consistency, latency), but brittleness and manageability can be addressed with generic, boiler plate patterns.
Coordination of distributed systems leads to boiler plate patterns

How to bring the ease of Spring Boot to a micro-services architecture?
and many more... what to choose?
Archaius
Curator
Asgaard
...
<appname>.properties<appname>-<envname>.ymlapplication.properties applies to all applications and environmentsDEMO
Consumers of config server can use client library as Spring Boot plugin
Features:
Environment from serverEnvironment@RefreshScope for atomic changes to beans via Spring lifecycle@ConfigurationPropertiesEnvironmentChangeEvent with list of properties that changedDEMO
@EnableConfigurationProperties(MyProps)
public class Application {
@Autowired
private MyProps props
@RefreshScope
@Bean
public Service service() {
new Service(props.name)
}
}
/restart closes application context and refreshes itDEMO
@EnableEurekaClient auto registers instance in server@EnableEurekaClient
public class Application {
}
DEMO
@HystrixCommand to the rescue@EnableHystrix via starter pomDEMO
private String getDefaultMessage() {
return "Hello World Default";
}
@HystrixCommand(fallbackMethod="getDefaultMessage")
public String getMessage() {
return restTemplate.getForObject(/*...*/);
}
@HystrixCommand(fallbackMethod="getDefaultMessage")
public Future<String> getMessageFuture() {
return new AsyncResult<String>() {
public String invoke() {
return restTemplate.getForObject(/*...*/);
}
};
}
//somewhere else
service.getMessageFuture().get();
@HystrixCommand(fallbackMethod="getDefaultMessage")
public Observable<String> getMessageRx() {
return new ObservableResult<String>() {
public String invoke() {
return restTemplate.getForObject(/*...*/);
}
};
}
//somewhere else
helloService.getMessageRx().subscribe(new Observer<String>() {
@Override public void onCompleted() {}
@Override public void onError(Throwable e) {}
@Override public void onNext(String s) {}
});
/metrics/hystrix.stream@EnableHystrixDashboardDEMO
DEMO
public interface HelloClient {
@RequestMapping(method = RequestMethod.GET,
value = "/hello")
Message hello();
@RequestMapping(method = RequestMethod.POST,
value = "/hello",
consumes = "application/json")
Message hello(Message message);
}
zuul.proxy.route.customers: /customersHystrix->Ribbon->Eureka to forward requests to appropriate service@EnableZuulProxy
@Controller
class Application {
@RequestMapping("/")
String home() {
return 'redirect:/index.html#/customers'
}
}
DEMO
DynamicStringProperty myprop = DynamicPropertyFactory.getInstance()
.getStringProperty("my.prop");
someMethod(myprop.get());
Dynamic*Properties to find values via Spring Environmentapplication.{properties,yml} and/or Spring Cloud Config Server?destination=x/bus/env sends environment updates/bus/refresh sends a refresh commandDEMO
| spring-cloud-starter | spring-cloud-starter-hystrix |
| spring-cloud-starter-bus-amqp | spring-cloud-starter-hystrix-dashboard |
| spring-cloud-starter-cloudfoundry | spring-cloud-starter-turbine |
| spring-cloud-starter-eureka | spring-cloud-starter-zuul |
| spring-cloud-starter-eureka-server |
/
#