update
@ -12,6 +12,18 @@
|
||||
<artifactId>02-customer</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zipkin</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
|
||||
@ -20,7 +32,10 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
|
||||
|
@ -10,11 +10,19 @@ import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
|
||||
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@RestController
|
||||
@RefreshScope
|
||||
public class CustomerController {
|
||||
|
||||
@Value("${env}")
|
||||
private String env;
|
||||
|
||||
|
||||
|
||||
@Value("${version}")
|
||||
private String version;
|
||||
|
||||
@ -32,6 +40,14 @@ public class CustomerController {
|
||||
|
||||
@Autowired
|
||||
private OtherServiceClient otherServiceClient;
|
||||
|
||||
|
||||
@GetMapping("/env")
|
||||
public String env() {
|
||||
return env;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/version")
|
||||
public String version() throws InterruptedException {
|
||||
Thread.sleep(3000);
|
||||
|
@ -1,39 +0,0 @@
|
||||
server:
|
||||
port: 8080
|
||||
#指定Eureka服务地址
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://root:root@localhost:8761/eureka,http://root:root@localhost:8762/eureka
|
||||
#每隔多久去更新一下本地的注册表缓存信息
|
||||
registry-fetch-interval-seconds: 30
|
||||
instance:
|
||||
#心跳间隔
|
||||
lease-renewal-interval-in-seconds: 30
|
||||
#多久没法送,就认为你宕机了
|
||||
lease-expiration-duration-in-seconds: 90
|
||||
|
||||
#指定具体服务的负载均衡策略
|
||||
SEARCH: #编写服务名称
|
||||
ribbon:
|
||||
# NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList
|
||||
NFLoadBalancerRuleClassName: com.netflix.loadbalancer.WeightedResponseTimeRule
|
||||
|
||||
#feign和hystrix主件整合
|
||||
feign:
|
||||
hystrix:
|
||||
enabled: true
|
||||
|
||||
version: v1
|
||||
#指定服务名称
|
||||
spring:
|
||||
application:
|
||||
name: CUSTOMER-${version}
|
||||
rabbitmq:
|
||||
port: 5672
|
||||
username: test
|
||||
password: test
|
||||
virtual-host: /test
|
||||
hystrix:
|
||||
dashboard:
|
||||
proxy-stream-allow-list: localhost
|
40
02-customer/src/main/resources/bootstrap.yml
Normal file
@ -0,0 +1,40 @@
|
||||
#指定Eureka服务地址
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://root:root@localhost:8761/eureka,http://root:root@localhost:8762/eureka
|
||||
|
||||
|
||||
|
||||
|
||||
version: v1
|
||||
#指定服务名称
|
||||
spring:
|
||||
application:
|
||||
name: CUSTOMER-${version}
|
||||
cloud:
|
||||
config:
|
||||
discovery:
|
||||
enabled: true
|
||||
service-id: CONFIG
|
||||
profile: dev
|
||||
sleuth:
|
||||
sampler:
|
||||
probability: 1 #百分之多少的sleuth信息需要输出到zipkin
|
||||
zipkin:
|
||||
base-url: http://127.0.0.1:9411/ #指定zipkin的地址
|
||||
sender:
|
||||
type: rabbit
|
||||
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
|
||||
#CONFIG - CUSTOMER-v1-dev.yml
|
||||
|
||||
logging:
|
||||
level:
|
||||
org.springframework.web.servlet.DispatcherServlet: DEBUG
|
@ -11,6 +11,10 @@
|
||||
|
||||
<artifactId>03-search</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zipkin</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
@ -26,4 +26,13 @@ spring:
|
||||
myMessage:
|
||||
consumer:
|
||||
acknowledgeMode: MANUAL
|
||||
sleuth:
|
||||
sampler:
|
||||
probability: 1 #百分之多少的sleuth信息需要输出到zipkin
|
||||
zipkin:
|
||||
base-url: http://127.0.0.1:9411/ #指定zipkin的地址
|
||||
|
||||
|
||||
logging:
|
||||
level:
|
||||
org.springframework.web.servlet.DispatcherServlet: DEBUG
|
@ -11,10 +11,27 @@
|
||||
|
||||
<artifactId>07-config</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config-server</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -2,8 +2,14 @@ package cn.zyjblogs;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.cloud.config.server.EnableConfigServer;
|
||||
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigServer
|
||||
@ServletComponentScan("cn.zyjblogs.filter")
|
||||
public class ConfigApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConfigApplication.class,args);
|
||||
|
62
07-config/src/main/java/cn/zyjblogs/filter/UrlFilter.java
Normal file
@ -0,0 +1,62 @@
|
||||
package cn.zyjblogs.filter;
|
||||
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@WebFilter("/*")
|
||||
public class UrlFilter implements Filter {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
HttpServletRequest httpServletRequest= (HttpServletRequest) servletRequest;
|
||||
String url=httpServletRequest.getRequestURI();
|
||||
System.out.println(url);
|
||||
if(!url.endsWith("/actuator/bus-refresh")){
|
||||
filterChain.doFilter(servletRequest,servletResponse);
|
||||
return;
|
||||
}
|
||||
String body=(httpServletRequest).toString();
|
||||
System.out.println("original body: "+ body);
|
||||
RequestWrapper requestWrapper=new RequestWrapper(httpServletRequest);
|
||||
filterChain.doFilter(requestWrapper,servletResponse);
|
||||
}
|
||||
private class RequestWrapper extends HttpServletRequestWrapper {
|
||||
public RequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
byte[] bytes = new byte[0];
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
|
||||
ServletInputStream servletInputStream = new ServletInputStream() {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return byteArrayInputStream.read() == -1 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener listener) {
|
||||
|
||||
}
|
||||
};
|
||||
return servletInputStream;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 81
|
||||
port: 10000
|
||||
|
||||
eureka:
|
||||
client:
|
||||
@ -9,8 +9,23 @@ eureka:
|
||||
#指定服务名称
|
||||
spring:
|
||||
application:
|
||||
name: OTHER-SERVICE #other-service
|
||||
|
||||
# 指定代理的第三方服务
|
||||
sidecar:
|
||||
port: 7001
|
||||
name: CONFIG #other-service
|
||||
cloud:
|
||||
config:
|
||||
server:
|
||||
git:
|
||||
basedir: E:\config # 本地仓库地址
|
||||
username: xxxxx@xxxxx.com #远程仓库的用户名
|
||||
password: xxxxx #远程仓库的密码
|
||||
uri: https://gitee.com/zyjblog/config-resp.git
|
||||
rabbitmq:
|
||||
virtual-host: /test
|
||||
host: localhost
|
||||
username: test
|
||||
password: test
|
||||
port: 5672
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
|
36
README.en.md
@ -1,36 +0,0 @@
|
||||
# springcloud
|
||||
|
||||
#### Description
|
||||
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
16
docker/docker-compose.yml
Normal file
@ -0,0 +1,16 @@
|
||||
version: "3.1"
|
||||
services:
|
||||
zipkin:
|
||||
image: daocloud.io/daocloud/zipkin:latest
|
||||
#image: docker.io/openzipkin/zipkin:latest
|
||||
restart: always
|
||||
container_name: zipkin
|
||||
ports:
|
||||
- 9411:9411
|
||||
environment:
|
||||
- RABBIT_ADDRESSES=10.27.10.123:5672
|
||||
- RABBIT_USER=test
|
||||
- RABBIT_PASSWORD=test
|
||||
- RABBIT_VIRTUAL_HOST=/test
|
||||
- STORAGE_TYPE=elasticsearch
|
||||
- ES_HOSTS=http://10.27.10.123:9200
|
BIN
images/1605019839175.png
Normal file
After Width: | Height: | Size: 256 KiB |
BIN
images/1605103387256.png
Normal file
After Width: | Height: | Size: 111 KiB |
BIN
images/1605103421256.png
Normal file
After Width: | Height: | Size: 112 KiB |
BIN
images/1605103436874.png
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
images/1605104987931.png
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
images/1605106759891.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
images/1605106760380.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
images/20190325232054468.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
images/image-20201111095513133.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
images/image-20201111095518705.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
images/image-20201111110217411.png
Normal file
After Width: | Height: | Size: 133 KiB |
BIN
images/image-20201111132523595.png
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
images/image-20201111134022333.png
Normal file
After Width: | Height: | Size: 190 KiB |
BIN
images/image-20201111155409030.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
images/image-20201111162630381.png
Normal file
After Width: | Height: | Size: 217 KiB |
BIN
images/image-20201111164239591.png
Normal file
After Width: | Height: | Size: 6.0 KiB |
BIN
images/image-20201111181650929.png
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
images/image-20201112110708902.png
Normal file
After Width: | Height: | Size: 142 KiB |
BIN
images/image-20201112113609523.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
images/image-20201112132217601.png
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
images/image-20201112135410803.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
images/image-20201112135429409.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
images/image-20201112140037987.png
Normal file
After Width: | Height: | Size: 157 KiB |
BIN
images/image-20201112140312697.png
Normal file
After Width: | Height: | Size: 98 KiB |
BIN
images/image-20201112141523371.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
images/image-20201112145449105.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
images/image-20201112151632111.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
images/image-20201112155652269.png
Normal file
After Width: | Height: | Size: 8.3 KiB |
BIN
images/image-20201112155707148.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
images/image-20201112160258956.png
Normal file
After Width: | Height: | Size: 179 KiB |
BIN
images/image-20201112165325023.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
images/image-20201112165641574.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
images/image-20201112173342142.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
images/image-20201112180552221.png
Normal file
After Width: | Height: | Size: 173 KiB |
BIN
images/image-20201113093057704.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
images/image-20201113094055276.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
images/image-20201113102316294.png
Normal file
After Width: | Height: | Size: 76 KiB |
BIN
images/image-20201113103152115.png
Normal file
After Width: | Height: | Size: 116 KiB |
BIN
images/image-20201113104134210.png
Normal file
After Width: | Height: | Size: 107 KiB |
BIN
images/image-20201113113814310.png
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
images/image-20201113114050201.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
images/image-20201113114131931.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
images/image-20201113120733998.png
Normal file
After Width: | Height: | Size: 127 KiB |
BIN
images/image-20201113121001855.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
images/image-20201113121035781.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
images/image-20201113131325996.png
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
images/image-20201113133658258.png
Normal file
After Width: | Height: | Size: 92 KiB |
BIN
images/image-20201113133713872.png
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
images/image-20201113133745985.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
images/image-20201113153443738.png
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
images/image-20201113160658535.png
Normal file
After Width: | Height: | Size: 87 KiB |
BIN
images/image-20201113160724897.png
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
images/image-20201113164636525.png
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
images/image-20201113164930192.png
Normal file
After Width: | Height: | Size: 98 KiB |
BIN
images/image-20201113165759501.png
Normal file
After Width: | Height: | Size: 427 KiB |