diff --git a/README.md b/README.md index a5b2be0cd3adc35a07cdf62c20ae1140f862ab74..ac729092d44fae342608e10025144bd23aab6a13 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/docker-compose.yml b/docker-compose.yml index b825dd5df76b04c2db8ce304cc8db212eac896c9..50efcee448ecb95d530bdf6b153d6b5e9eb05b5a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/pom.xml b/pom.xml index f61e9d6f581de719dd9f12cbc4cc2627e2e53488..85fab7e961f9c9e2d8662dfeff607cdf0ae78a4a 100644 --- a/pom.xml +++ b/pom.xml @@ -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> diff --git a/spring-petclinic-hystrix-dashboard/pom.xml b/spring-petclinic-hystrix-dashboard/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..19edba8978891c1b726642d95e88bb6b6d148680 --- /dev/null +++ b/spring-petclinic-hystrix-dashboard/pom.xml @@ -0,0 +1,62 @@ +<?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> diff --git a/spring-petclinic-hystrix-dashboard/src/main/java/org/springframework/samples/petclinic/dashboard/HystrixDashboardApplication.java b/spring-petclinic-hystrix-dashboard/src/main/java/org/springframework/samples/petclinic/dashboard/HystrixDashboardApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..0ecd670faf47f06bb885e118ea65f5c5a4743af3 --- /dev/null +++ b/spring-petclinic-hystrix-dashboard/src/main/java/org/springframework/samples/petclinic/dashboard/HystrixDashboardApplication.java @@ -0,0 +1,25 @@ +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"; + } +} diff --git a/spring-petclinic-hystrix-dashboard/src/main/resources/bootstrap.yml b/spring-petclinic-hystrix-dashboard/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000000000000000000000000000000000..5e52f8d4677bffa2b62d6ba805f699fb8bddd241 --- /dev/null +++ b/spring-petclinic-hystrix-dashboard/src/main/resources/bootstrap.yml @@ -0,0 +1,12 @@ +spring: + cloud: + config: + uri: http://localhost:8888 + application: + name: hystrix-dashboard +--- +spring: + profiles: docker + cloud: + config: + uri: http://config-server:8888 diff --git a/spring-petclinic-hystrix-dashboard/src/main/resources/logback-spring.xml b/spring-petclinic-hystrix-dashboard/src/main/resources/logback-spring.xml new file mode 100644 index 0000000000000000000000000000000000000000..5d03f79413815de8cfffdc114e57b1cc53b68be4 --- /dev/null +++ b/spring-petclinic-hystrix-dashboard/src/main/resources/logback-spring.xml @@ -0,0 +1,6 @@ +<?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> diff --git a/spring-petclinic-hystrix-dashboard/src/test/java/org/springframework/samples/petclinic/dashboard/HystrixDashboardApplicationTests.java b/spring-petclinic-hystrix-dashboard/src/test/java/org/springframework/samples/petclinic/dashboard/HystrixDashboardApplicationTests.java new file mode 100644 index 0000000000000000000000000000000000000000..18bc6d7e569145f9a4dd1de55d5b2429c3d8ce9d --- /dev/null +++ b/spring-petclinic-hystrix-dashboard/src/test/java/org/springframework/samples/petclinic/dashboard/HystrixDashboardApplicationTests.java @@ -0,0 +1,16 @@ +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() { + } + +}