From d8e92f9d8de8d04bc0fd2c879d32f6171eb62c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20R=C3=A4del?= Date: Thu, 18 Aug 2016 21:36:05 +0200 Subject: [PATCH 1/6] Sample Hystrix implementation --- spring-cloud-hystrix/pom.xml | 49 +++++++++++++++ .../pom.xml | 62 +++++++++++++++++++ .../rest/consumer/GreetingService.java | 18 ++++++ .../consumer/RestConsumerApplication.java | 28 +++++++++ .../resources/templates/greeting-view.html | 9 +++ .../pom.xml | 40 ++++++++++++ .../rest/producer/GreetingController.java | 10 +++ .../producer/RestProducerApplication.java | 20 ++++++ .../src/main/resources/application.properties | 1 + 9 files changed, 237 insertions(+) create mode 100644 spring-cloud-hystrix/pom.xml create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties diff --git a/spring-cloud-hystrix/pom.xml b/spring-cloud-hystrix/pom.xml new file mode 100644 index 0000000000..f7394d729e --- /dev/null +++ b/spring-cloud-hystrix/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + com.baeldung.spring.cloud + spring-cloud-hystrix + 1.0.0-SNAPSHOT + + spring-cloud-hystrix-rest-producer + spring-cloud-hystrix-rest-consumer + + pom + + Spring Cloud Hystrix + Spring Cloud Hystrix Demo + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + .. + + + + UTF-8 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + org.springframework.boot + spring-boot-maven-plugin + 1.4.0.RELEASE + + + + + diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml new file mode 100644 index 0000000000..b9da24b9a5 --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + spring-cloud-hystrix-rest-consumer + 1.0.0-SNAPSHOT + jar + + Spring Cloud Hystrix REST Consumer + Spring Cloud Hystrix Sample Implementation + + + com.baeldung.spring.cloud + spring-cloud-hystrix + 1.0.0-SNAPSHOT + .. + + + + + org.springframework.cloud + spring-cloud-starter-hystrix + 1.1.5.RELEASE + + + org.springframework.boot + spring-boot-starter-web + 1.4.0.RELEASE + + + org.springframework.boot + spring-boot-starter-thymeleaf + 1.4.0.RELEASE + + + + + + + org.springframework.cloud + spring-cloud-starter-parent + Brixton.SR4 + pom + import + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java new file mode 100644 index 0000000000..d3d5e6e047 --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingService.java @@ -0,0 +1,18 @@ +package com.baeldung.spring.cloud.hystrix.rest.consumer; + +import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +@Service +public class GreetingService { + @HystrixCommand(fallbackMethod = "defaultGreeting") + public String getGreeting(String username) { + return new RestTemplate().getForObject("http://localhost:9090/greeting/{username}", String.class, username); + } + + private String defaultGreeting(String username) { + return "Hello User!"; + } +} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java new file mode 100644 index 0000000000..051fd9a9bb --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java @@ -0,0 +1,28 @@ +package com.baeldung.spring.cloud.hystrix.rest.consumer; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +@SpringBootApplication +@EnableCircuitBreaker +@Controller +public class RestConsumerApplication { + @Autowired + private GreetingService greetingService; + + public static void main(String[] args) { + SpringApplication.run(RestConsumerApplication.class, args); + } + + @RequestMapping("/get-greeting/{username}") + public String getGreeting(Model model, @PathVariable("username") String username) { + model.addAttribute("greeting", greetingService.getGreeting(username)); + return "greeting-view"; + } +} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html new file mode 100644 index 0000000000..6cb70edf2d --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html @@ -0,0 +1,9 @@ + + + + Greetings from Hystrix + + +

+ + \ No newline at end of file diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml new file mode 100644 index 0000000000..44e373c8ac --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + spring-cloud-hystrix-rest-producer + 1.0.0-SNAPSHOT + jar + + Spring Cloud Hystrix REST Producer + Spring Cloud Hystrix Sample REST Producer Implementation + + + com.baeldung.spring.cloud + spring-cloud-hystrix + 1.0.0-SNAPSHOT + .. + + + + + org.springframework.boot + spring-boot-starter-web + 1.4.0.RELEASE + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java new file mode 100644 index 0000000000..81541b4f8f --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/GreetingController.java @@ -0,0 +1,10 @@ +package com.baeldung.spring.cloud.hystrix.rest.producer; + +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +public interface GreetingController { + @RequestMapping("/greeting/{username}") + String greeting(@PathVariable("username") String username); +} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java new file mode 100644 index 0000000000..9496d4760d --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/producer/RestProducerApplication.java @@ -0,0 +1,20 @@ +package com.baeldung.spring.cloud.hystrix.rest.producer; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@RestController +public class RestProducerApplication implements GreetingController { + public static void main(String[] args) { + SpringApplication.run(RestProducerApplication.class, args); + } + + @Override + public String greeting(@PathVariable("username") String username) { + return String.format("Hello %s!\n", username); + } +} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties new file mode 100644 index 0000000000..5ff028510d --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=9090 \ No newline at end of file From e618804c75dde7707536e7933d2ea696989aaf74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20R=C3=A4del?= Date: Fri, 19 Aug 2016 07:29:03 +0200 Subject: [PATCH 2/6] Added Hystrix Dashboard --- .../spring-cloud-hystrix-rest-consumer/pom.xml | 10 ++++++++++ .../hystrix/rest/consumer/RestConsumerApplication.java | 3 +++ 2 files changed, 13 insertions(+) diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml index b9da24b9a5..c9be67c302 100644 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/pom.xml @@ -23,6 +23,11 @@ spring-cloud-starter-hystrix 1.1.5.RELEASE + + org.springframework.cloud + spring-cloud-starter-hystrix-dashboard + 1.1.5.RELEASE + org.springframework.boot spring-boot-starter-web @@ -33,6 +38,11 @@ spring-boot-starter-thymeleaf 1.4.0.RELEASE + + org.springframework.boot + spring-boot-starter-actuator + 1.4.0.RELEASE + diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java index 051fd9a9bb..9df745b1c6 100644 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerApplication.java @@ -4,6 +4,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.cloud.netflix.hystrix.EnableHystrix; +import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; @@ -11,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping; @SpringBootApplication @EnableCircuitBreaker +@EnableHystrixDashboard @Controller public class RestConsumerApplication { @Autowired From da1bdf90bfa524408821adb0d91447c0dd7663cd Mon Sep 17 00:00:00 2001 From: Christian Raedel Date: Mon, 22 Aug 2016 19:57:11 +0200 Subject: [PATCH 3/6] Added Feign Client --- spring-cloud-hystrix/pom.xml | 1 + .../pom.xml | 82 +++++++++++++++++++ .../hystrix/rest/consumer/GreetingClient.java | 21 +++++ .../RestConsumerFeignApplication.java | 32 ++++++++ .../resources/templates/greeting-view.html | 9 ++ 5 files changed, 145 insertions(+) create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html diff --git a/spring-cloud-hystrix/pom.xml b/spring-cloud-hystrix/pom.xml index f7394d729e..2768a4f05b 100644 --- a/spring-cloud-hystrix/pom.xml +++ b/spring-cloud-hystrix/pom.xml @@ -9,6 +9,7 @@ spring-cloud-hystrix-rest-producer spring-cloud-hystrix-rest-consumer + spring-cloud-hystrix-feign-rest-consumer pom diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml new file mode 100644 index 0000000000..d2716e897e --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + spring-cloud-hystrix-feign-rest-consumer + 1.0.0-SNAPSHOT + jar + + Spring Cloud Hystrix Feign REST Consumer + Spring Cloud Hystrix Feign Sample Implementation + + + com.baeldung.spring.cloud + spring-cloud-hystrix + 1.0.0-SNAPSHOT + .. + + + + + com.baeldung.spring.cloud + spring-cloud-hystrix-rest-producer + 1.0.0-SNAPSHOT + + + org.springframework.cloud + spring-cloud-starter-hystrix + 1.1.5.RELEASE + + + org.springframework.cloud + spring-cloud-starter-hystrix-dashboard + 1.1.5.RELEASE + + + org.springframework.cloud + spring-cloud-starter-feign + 1.1.5.RELEASE + + + org.springframework.boot + spring-boot-starter-web + 1.4.0.RELEASE + + + org.springframework.boot + spring-boot-starter-thymeleaf + 1.4.0.RELEASE + + + org.springframework.boot + spring-boot-starter-actuator + 1.4.0.RELEASE + + + + + + + org.springframework.cloud + spring-cloud-starter-parent + Brixton.SR4 + pom + import + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java new file mode 100644 index 0000000000..e152b8233f --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java @@ -0,0 +1,21 @@ +package com.baeldung.spring.cloud.hystrix.rest.consumer; + +import com.baeldung.spring.cloud.hystrix.rest.producer.GreetingController; +import org.springframework.cloud.netflix.feign.FeignClient; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.PathVariable; + +@FeignClient( + name = "rest-producer", + url = "http://localhost:9090/greeting/{username}", + fallback = GreetingClient.GreetingClientFallback.class +) +public interface GreetingClient extends GreetingController { + @Component + public static class GreetingClientFallback implements GreetingClient { + @Override + public String greeting(@PathVariable("username") String username) { + return "Hello User!"; + } + } +} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java new file mode 100644 index 0000000000..b97d84eaf2 --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/RestConsumerFeignApplication.java @@ -0,0 +1,32 @@ +package com.baeldung.spring.cloud.hystrix.rest.consumer; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.cloud.netflix.feign.EnableFeignClients; +import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +@SpringBootApplication +@EnableCircuitBreaker +@EnableHystrixDashboard +@EnableFeignClients +@Controller +public class RestConsumerFeignApplication { + @Autowired + private GreetingClient greetingClient; + + public static void main(String[] args) { + SpringApplication.run(RestConsumerFeignApplication.class, args); + } + + @RequestMapping("/get-greeting/{username}") + public String getGreeting(Model model, @PathVariable("username") String username) { + model.addAttribute("greeting", greetingClient.greeting(username)); + return "greeting-view"; + } +} diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html new file mode 100644 index 0000000000..6cb70edf2d --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html @@ -0,0 +1,9 @@ + + + + Greetings from Hystrix + + +

+ + \ No newline at end of file From f28343cd54296b6efced09e96d6294a0adcba113 Mon Sep 17 00:00:00 2001 From: Christian Raedel Date: Mon, 22 Aug 2016 23:45:32 +0200 Subject: [PATCH 4/6] Added application configurations --- .../spring/cloud/hystrix/rest/consumer/GreetingClient.java | 3 ++- .../src/main/resources/application.properties | 1 + .../src/main/resources/application.properties | 1 + .../src/main/resources/application.properties | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties create mode 100644 spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java index e152b8233f..d12ef2a583 100644 --- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java +++ b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java @@ -7,7 +7,8 @@ import org.springframework.web.bind.annotation.PathVariable; @FeignClient( name = "rest-producer", - url = "http://localhost:9090/greeting/{username}", + url = "http://localhost:9090", + //path = "/greeting/{username}", fallback = GreetingClient.GreetingClientFallback.class ) public interface GreetingClient extends GreetingController { diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties new file mode 100644 index 0000000000..8d51d0c619 --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=8082 \ No newline at end of file diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties new file mode 100644 index 0000000000..a3ac65cee5 --- /dev/null +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=8080 \ No newline at end of file diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties index 5ff028510d..0560a60908 100644 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties @@ -1 +1,2 @@ +spring.application.name=rest-producer server.port=9090 \ No newline at end of file From 647d35cafb9d8502370a2776e911398b4ddc313b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20R=C3=A4del?= Date: Tue, 23 Aug 2016 02:51:49 +0200 Subject: [PATCH 5/6] Small formatting fixes. --- .../spring/cloud/hystrix/rest/consumer/GreetingClient.java | 7 +++---- .../src/main/resources/application.properties | 2 +- .../src/main/resources/templates/greeting-view.html | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/templates/greeting-view.html | 2 +- .../src/main/resources/application.properties | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java index d12ef2a583..b715e8c052 100644 --- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java +++ b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/java/com/baeldung/spring/cloud/hystrix/rest/consumer/GreetingClient.java @@ -6,10 +6,9 @@ import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.PathVariable; @FeignClient( - name = "rest-producer", - url = "http://localhost:9090", - //path = "/greeting/{username}", - fallback = GreetingClient.GreetingClientFallback.class + name = "rest-producer", + url = "http://localhost:9090", + fallback = GreetingClient.GreetingClientFallback.class ) public interface GreetingClient extends GreetingController { @Component diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties index 8d51d0c619..3cf12afeb9 100644 --- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties +++ b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/application.properties @@ -1 +1 @@ -server.port=8082 \ No newline at end of file +server.port=8082 diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html index 6cb70edf2d..302390fde0 100644 --- a/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html +++ b/spring-cloud-hystrix/spring-cloud-hystrix-feign-rest-consumer/src/main/resources/templates/greeting-view.html @@ -6,4 +6,4 @@

- \ No newline at end of file + diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties index a3ac65cee5..4c00e40deb 100644 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/application.properties @@ -1 +1 @@ -server.port=8080 \ No newline at end of file +server.port=8080 diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html index 6cb70edf2d..302390fde0 100644 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-consumer/src/main/resources/templates/greeting-view.html @@ -6,4 +6,4 @@

- \ No newline at end of file + diff --git a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties index 0560a60908..9ce9d88ffb 100644 --- a/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties +++ b/spring-cloud-hystrix/spring-cloud-hystrix-rest-producer/src/main/resources/application.properties @@ -1,2 +1,2 @@ spring.application.name=rest-producer -server.port=9090 \ No newline at end of file +server.port=9090 From 5b4c8129c767c6f29914b41f939134d7bff16489 Mon Sep 17 00:00:00 2001 From: Slavisa Baeldung Date: Fri, 26 Aug 2016 09:06:50 +0200 Subject: [PATCH 6/6] BAEL-169 - Sources for Spring Cloud Hystrix article --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 8b2d0b3ff1..90072073a6 100644 --- a/pom.xml +++ b/pom.xml @@ -86,6 +86,7 @@ spring-rest-angular spring-rest-docs spring-cloud-config + spring-cloud-hystrix spring-security-basic-auth spring-security-custom-permission