Skip to content
Snippets Groups Projects
Commit ece0dc19 authored by Antoine Rey's avatar Antoine Rey Committed by Maciej Szarliński
Browse files

Add Hystrix Dashboard (#115)

* Add circuit breaker to the getVisitsForPets method

* Use Collections.emptyMap()

* Fallback method with private visibility

* Unit test Hystrix fallback method

* #17 Add a Hystrix Dashboard application

* Fix hystrix-dashboard container name
parent c94a088e
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,10 @@ If everything goes well, you can access the following services at given location
* Customers, Vets and Visits Services - random port, check Eureka Dashboard
* Tracing Server (Zipkin) - http://localhost:9411/zipkin/ (we use [openzipkin](https://github.com/openzipkin/zipkin/tree/master/zipkin-server))
* Admin Server (Spring Boot Admin) - http://localhost:9090
* Hystrix Dashboard for Circuit Breaker pattern - http://localhost:7979 - On the home page is a form where you can enter
the URL for an event stream to monitor, for example the `api-gateway` service running locally: `http://localhost:8080/actuator/hystrix.stream`
or running into docker: `http://api-gateway:8080/actuator/hystrix.stream`
You can tell Config Server to use your local Git repository by using `local` Spring profile and setting
`GIT_REPO` environment variable, for example:
......
......@@ -80,3 +80,14 @@ services:
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
ports:
- 9090:9090
hystrix-dashboard:
image: mszarlinski/spring-petclinic-hystrix-dashboard
container_name: hystrix-dashboard
mem_limit: 512M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
ports:
- 7979:7979
......@@ -23,6 +23,7 @@
<module>spring-petclinic-config-server</module>
<module>spring-petclinic-discovery-server</module>
<module>spring-petclinic-api-gateway</module>
<module>spring-petclinic-hystrix-dashboard</module>
</modules>
<properties>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spring-petclinic-microservices</artifactId>
<groupId>org.springframework.samples</groupId>
<version>2.0.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-petclinic-hystrix-dashboard</artifactId>
<description>Circuit breaker dashboard with with Spring Cloud Netflix Hystrix</description>
<properties>
<docker.image.exposed.port>7979</docker.image.exposed.port>
<docker.image.dockerfile.dir>${basedir}/../docker</docker.image.dockerfile.dir>
</properties>
<dependencies>
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring Cloud -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>buildDocker</id>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
package org.springframework.samples.petclinic.dashboard;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@SpringBootApplication
@EnableDiscoveryClient
@EnableHystrixDashboard
@Controller
public class HystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class, args);
}
@RequestMapping("/")
public String home() {
return "forward:/hystrix";
}
}
spring:
cloud:
config:
uri: http://localhost:8888
application:
name: hystrix-dashboard
---
spring:
profiles: docker
cloud:
config:
uri: http://config-server:8888
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<!-- Required for Loglevel managment into the Spring Petclinic Admin Server-->
<jmxConfigurator/>
</configuration>
package org.springframework.samples.petclinic.dashboard;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@SpringBootTest
class HystrixDashboardApplicationTests {
@Test
void contextLoads() {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment