Ensure server port is registered late enough with Eureka server

Because we were using Lifecycle to kick off the eureka registration the
local server port wasn't available yet. The change is to use an
ApplicationListener and listen for the event that contains the container
with its port instead.

Fixes gh-15
This commit is contained in:
Dave Syer
2014-09-29 10:52:37 +01:00
parent f41edfd483
commit 21eb52fa27
4 changed files with 124 additions and 11 deletions

View File

@@ -0,0 +1,80 @@
= Spring Cloud Netflix
This project provides Netflix OSS integrations for Spring Boot apps through autoconfiguration
and binding to the Spring Environment and other Spring programming model idioms.
== Service Discovery: Eureka Clients
Example eureka client:
```
@Configuration
@ComponentScan
@EnableAutoConfiguration
@EnableEurekaClient
@RestController
public class Application {
@RequestMapping("/")
public String home() {
return "Hello world";
}
public static void main(String[] args) {
new SpringApplicationBuilder(Application.class).web(true).run(args);
}
}
```
(i.e. utterly normal Spring Boot app). Configuration is required to locate the Eureka server. Example:
```
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8080/v2/
default.defaultZone: http://localhost:8080/v2/
```
The default application name, virtual host and non-secure port are taken from the `Environment` is
`${spring.application.name}`, `${spring.application.name}.mydomain.net` and `${server.port}` respectively.
== Service Discovery: Eureka Server
Example eureka server:
```
@Configuration
@EnableAutoConfiguration
@EnableEurekaServer
public class Application {
public static void main(String[] args) {
new SpringApplicationBuilder(Application.class).web(true).run(args);
}
}
```
The server has a home page with a UI, and HTTP API endpoints per the
normal Eureka functionality under `/v2/*`.
Eureka (apache -> tomcat) see https://github.com/cfregly/fluxcapacitor/wiki/NetflixOSS-FAQ#eureka-service-discovery-load-balancer[flux capacitor] and https://groups.google.com/forum/?fromgroups#!topic/eureka_netflix/g3p2r7gHnN0[google group discussion].
== Circuit Breaker: Hystrix Clients
== Circuit Breaker: Hystrix Dashboard
=== Turbine
== Declarative REST Client: Feign
== Client Side Load Balancer: Ribbon
== External Configuration: Archaius
== Router and Filter: Zuul