Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Spring e Eureka Service Discovery

Spring e Eureka Service Discovery

Apresentação para o 7masters Spring - Um exemplo prático de como integrar o spring e eureka da netflix

Breno Oliveira

June 29, 2017
Tweet

More Decks by Breno Oliveira

Other Decks in Technology

Transcript

  1. @EnableEurekaServer @SpringBootApplication public class EurekaServiceApplication { public static void main(String[]

    args) { SpringApplication.run(EurekaServiceApplication.class, args); } } eureka-service
  2. eureka-client @EnableDiscoveryClient @SpringBootApplication public class EurekaClientApplication { public static void

    main(String[] args) { SpringApplication.run(EurekaClientApplication.class, args); } }
  3. eureka-client @RestController class ServiceInstanceRestController { @Autowired private DiscoveryClient discoveryClient; @RequestMapping("/service-instances/{applicationName}")

    public List<ServiceInstance> serviceInstancesByApplicationName( @PathVariable String applicationName) { return this.discoveryClient.getInstances(applicationName); } }
  4. [{"host":"10.0.20.21","port":8080,"metadata":{},"instanceInfo": {"instanceId":"10.0.20.21:sevenmasters-client","app":"SEVENMASTERS- CLIENT","appGroupName":null,"ipAddr":"10.0.20.21","sid":"na","homePage l":"http://10.0.20.21:8080/","statusPageUrl":"http://10.0.20.21:8080/ info","healthCheckUrl":"http://10.0.20.21:8080/ health","secureHealthCheckUrl":null,"vipAddress":"sevenmasters- client","secureVipAddress":"sevenmasters-client","countryId": 1,"dataCenterInfo": {"@class":"com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo","na ":"MyOwn"},"hostName":"10.0.20.21","status":"UP","leaseInfo":

    {"renewalIntervalInSecs":30,"durationInSecs":90,"registrationTimestamp 1498655222633,"lastRenewalTimestamp":1498655222633,"evictionTimestamp" 0,"serviceUpTimestamp": 1498655221969},"isCoordinatingDiscoveryServer":false,"metadata": {},"lastUpdatedTimestamp":1498655222633,"lastDirtyTimestamp": 1498655221739,"actionType":"ADDED","asgName":null,"overriddenStatus":" KNOWN"},"uri":"http:// 10.0.20.21:8080","secure":false,"serviceId":"SEVENMASTERS-CLIENT"}]