This commit is contained in:
朱毅骏 2020-11-13 17:07:26 +08:00
parent 55f1fd11af
commit 8a4627cf95
68 changed files with 2226 additions and 109 deletions

View File

@ -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>

View File

@ -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);

View File

@ -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

View 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

View File

@ -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>

View File

@ -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

View File

@ -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>

View File

@ -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);

View 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;
}
}
}

View File

@ -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: "*"

View File

@ -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/)

2046
README.md

File diff suppressed because it is too large Load Diff

16
docker/docker-compose.yml Normal file
View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

BIN
images/1605103387256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

BIN
images/1605103421256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

BIN
images/1605103436874.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
images/1605104987931.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
images/1605106759891.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
images/1605106760380.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 KiB