Skip to content

Commit 353cd78

Browse files
committed
Hystrix & Eureka with Redis Cache Example
1 parent e17abe8 commit 353cd78

File tree

23 files changed

+1575
-0
lines changed

23 files changed

+1575
-0
lines changed

hystrix/hystrix-eureka-redis-sample-apps.graphml

Lines changed: 274 additions & 0 deletions
Large diffs are not rendered by default.

hystrix/hystrix-eureka-redis-sample-flowchart.graphml

Lines changed: 574 additions & 0 deletions
Large diffs are not rendered by default.

hystrix/hystrix-sample-dto/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>hystrix</artifactId>
7+
<groupId>com.fd</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>hystrix-sample-dto</artifactId>
13+
14+
15+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.fd.tryout.hystrix.dto;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
import java.io.Serializable;
9+
10+
/**
11+
* @author fdanismaz
12+
* date: 9/20/18 10:57 AM
13+
*/
14+
@Data
15+
@Builder
16+
@NoArgsConstructor
17+
@AllArgsConstructor
18+
public class User implements Serializable {
19+
20+
private static final long serialVersionUID = -1370535335902642073L;
21+
22+
private String id;
23+
private String name;
24+
private String email;
25+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>hystrix</artifactId>
7+
<groupId>com.fd</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>hystrix-sample-eureka-client</artifactId>
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.springframework.cloud</groupId>
16+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
17+
</dependency>
18+
19+
<dependency>
20+
<groupId>org.springframework.boot</groupId>
21+
<artifactId>spring-boot-starter-web</artifactId>
22+
</dependency>
23+
24+
<dependency>
25+
<groupId>com.fd</groupId>
26+
<artifactId>hystrix-sample-dto</artifactId>
27+
<version>1.0-SNAPSHOT</version>
28+
</dependency>
29+
</dependencies>
30+
31+
</project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.fd.tryout.hystrix.dto.eureka.client;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6+
7+
/**
8+
* @author fdanismaz
9+
* date: 9/20/18 10:59 AM
10+
*/
11+
@EnableDiscoveryClient
12+
@SpringBootApplication
13+
public class App {
14+
15+
public static void main(String[] args) {
16+
SpringApplication.run(App.class, args);
17+
}
18+
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.fd.tryout.hystrix.dto.eureka.client.controller;
2+
3+
import com.fd.tryout.hystrix.dto.User;
4+
import org.springframework.http.ResponseEntity;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.PathVariable;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
/**
11+
* @author fdanismaz
12+
* date: 9/20/18 11:03 AM
13+
*/
14+
@RestController
15+
@RequestMapping("/user")
16+
public class UserController {
17+
18+
@GetMapping("/{id}")
19+
public ResponseEntity<User> getUser(@PathVariable String id) {
20+
User user = User.builder().id("1").name("John Doe").email("john.doe@gmail.com").build();
21+
return ResponseEntity.ok().body(user);
22+
}
23+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
spring:
2+
application:
3+
name: fd-user-service
4+
5+
server:
6+
port: 9091
7+
servlet:
8+
contextPath: /test
9+
10+
eureka:
11+
client:
12+
serviceUrl:
13+
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
14+
instance:
15+
preferIpAddress: true
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>hystrix</artifactId>
7+
<groupId>com.fd</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>hystrix-sample-eureka-feign-client</artifactId>
13+
14+
<properties>
15+
<spring.cloud.starter.hystrix.version>1.4.5.RELEASE</spring.cloud.starter.hystrix.version>
16+
</properties>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.springframework.cloud</groupId>
21+
<artifactId>spring-cloud-starter-hystrix</artifactId>
22+
<version>${spring.cloud.starter.hystrix.version}</version>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>org.springframework.cloud</groupId>
27+
<artifactId>spring-cloud-starter-openfeign</artifactId>
28+
<exclusions>
29+
<exclusion>
30+
<groupId>ch.qos.logback</groupId>
31+
<artifactId>logback-classic</artifactId>
32+
</exclusion>
33+
34+
<exclusion>
35+
<groupId>org.apache.logging.log4j</groupId>
36+
<artifactId>log4j-to-slf4j</artifactId>
37+
</exclusion>
38+
</exclusions>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>org.springframework.cloud</groupId>
43+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
44+
<exclusions>
45+
<exclusion>
46+
<groupId>ch.qos.logback</groupId>
47+
<artifactId>logback-classic</artifactId>
48+
</exclusion>
49+
50+
<exclusion>
51+
<groupId>org.apache.logging.log4j</groupId>
52+
<artifactId>log4j-to-slf4j</artifactId>
53+
</exclusion>
54+
</exclusions>
55+
</dependency>
56+
57+
<dependency>
58+
<groupId>org.springframework.boot</groupId>
59+
<artifactId>spring-boot-starter-web</artifactId>
60+
<exclusions>
61+
<exclusion>
62+
<groupId>ch.qos.logback</groupId>
63+
<artifactId>logback-classic</artifactId>
64+
</exclusion>
65+
66+
<exclusion>
67+
<groupId>org.apache.logging.log4j</groupId>
68+
<artifactId>log4j-to-slf4j</artifactId>
69+
</exclusion>
70+
</exclusions>
71+
</dependency>
72+
73+
<dependency>
74+
<groupId>org.springframework.boot</groupId>
75+
<artifactId>spring-boot-starter-data-redis</artifactId>
76+
<exclusions>
77+
<exclusion>
78+
<groupId>ch.qos.logback</groupId>
79+
<artifactId>logback-classic</artifactId>
80+
</exclusion>
81+
82+
<exclusion>
83+
<groupId>org.apache.logging.log4j</groupId>
84+
<artifactId>log4j-to-slf4j</artifactId>
85+
</exclusion>
86+
</exclusions>
87+
</dependency>
88+
89+
<dependency>
90+
<groupId>com.fd</groupId>
91+
<artifactId>hystrix-sample-dto</artifactId>
92+
<version>1.0-SNAPSHOT</version>
93+
</dependency>
94+
95+
<dependency>
96+
<groupId>org.apache.logging.log4j</groupId>
97+
<artifactId>log4j-core</artifactId>
98+
</dependency>
99+
100+
<dependency>
101+
<groupId>org.apache.logging.log4j</groupId>
102+
<artifactId>log4j-slf4j-impl</artifactId>
103+
</dependency>
104+
</dependencies>
105+
106+
</project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.fd.tryout.hystrix.eureka.feign.client;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.openfeign.EnableFeignClients;
6+
7+
/**
8+
* @author fdanismaz
9+
* date: 9/20/18 11:09 AM
10+
*/
11+
@EnableFeignClients
12+
@SpringBootApplication
13+
public class App {
14+
15+
public static void main(String[] args) {
16+
SpringApplication.run(App.class, args);
17+
}
18+
19+
}

0 commit comments

Comments
 (0)