├── config-repo
├── didispace-dev.properties
├── didispace-prod.properties
├── didispace-test.properties
├── didispace.properties
└── api-gateway.properties
├── config-server-eureka
├── src
│ └── main
│ │ ├── resources
│ │ ├── didispace.properties
│ │ ├── didispace-dev.properties
│ │ ├── didispace-prod.properties
│ │ ├── didispace-test.properties
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── Application.java
└── pom.xml
├── config-server
├── src
│ └── main
│ │ ├── resources
│ │ ├── didispace-dev.properties
│ │ ├── didispace-prod.properties
│ │ ├── didispace-test.properties
│ │ ├── application.properties
│ │ ├── config-server.keystore
│ │ └── didispace.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── Application.java
└── pom.xml
├── config-server-eureka-kafka
├── src
│ └── main
│ │ ├── resources
│ │ ├── didispace.properties
│ │ ├── didispace-dev.properties
│ │ ├── didispace-prod.properties
│ │ ├── didispace-test.properties
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── Application.java
└── pom.xml
├── config-server-eureka-rabbit
├── src
│ └── main
│ │ ├── resources
│ │ ├── didispace.properties
│ │ ├── didispace-dev.properties
│ │ ├── didispace-prod.properties
│ │ ├── didispace-test.properties
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── Application.java
└── pom.xml
├── spring_cloud_in_action
└── config-repo
│ ├── didispace-dev.properties
│ ├── didispace-prod.properties
│ ├── didispace-test.properties
│ ├── didispace.properties
│ └── api-gateway.properties
├── spring-boot-hello
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── application-dev.properties
│ │ │ ├── application-prod.properties
│ │ │ ├── application-test.properties
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── didispace
│ │ │ ├── web
│ │ │ └── HelloController.java
│ │ │ └── HelloApplication.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── HelloApplicationTests.java
└── pom.xml
├── hystrix-dashboard
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── HystrixDashboardApplication.java
└── pom.xml
├── api-gateway
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── HelloController.java
│ │ ├── Application.java
│ │ └── filter
│ │ └── AccessFilter.java
└── pom.xml
├── eureka-server
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── Application.java
└── pom.xml
├── feign-consumer
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── web
│ │ ├── RefactorHelloService.java
│ │ ├── HelloService.java
│ │ ├── User.java
│ │ ├── HelloServiceFallback.java
│ │ └── ConsumerController.java
│ │ └── ConsumerApplication.java
└── pom.xml
├── hello-service
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── HelloApplication.java
│ │ ├── web
│ │ ├── RefactorHelloController.java
│ │ ├── User.java
│ │ └── HelloController.java
│ │ └── indicator
│ │ └── RocketMQHealthIndicator.java
└── pom.xml
├── zipkin-server
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── ZipkinApplication.java
└── pom.xml
├── turbine-amqp
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── TurbineApplication.java
└── pom.xml
├── eureka-server-ha
├── src
│ └── main
│ │ ├── resources
│ │ ├── application-peer1.properties
│ │ ├── application-peer2.properties
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── Application.java
└── pom.xml
├── rabbitmq-hello
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── didispace
│ │ │ ├── HelloApplication.java
│ │ │ └── rabbit
│ │ │ ├── RabbitConfig.java
│ │ │ ├── Sender.java
│ │ │ └── Receiver.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── HelloApplicationTests.java
└── pom.xml
├── api-gateway-dynamic-route
├── src
│ └── main
│ │ ├── resources
│ │ └── bootstrap.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── Application.java
└── pom.xml
├── api-gateway-dynamic-filter
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── FilterConfiguration.java
│ │ └── Application.java
├── filter
│ ├── pre
│ │ └── PreFilter.groovy
│ └── post
│ │ └── PostFilter.groovy
└── pom.xml
├── api-gateway-exception
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── filter
│ │ ├── DidiErrorAttributes.java
│ │ ├── DidiFilterProcessor.java
│ │ ├── post
│ │ │ └── ThrowExceptionPostFilter.java
│ │ ├── error
│ │ │ ├── ErrorExtFilter.java
│ │ │ └── ErrorFilter.java
│ │ └── pre
│ │ │ └── ThrowExceptionFilter.java
│ │ └── Application.java
└── pom.xml
├── trace-2
├── src
│ └── main
│ │ ├── resources
│ │ ├── application.properties
│ │ └── logback-spring.xml
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── TraceApplication.java
└── pom.xml
├── config-client
├── src
│ └── main
│ │ ├── resources
│ │ └── bootstrap.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── Application.java
│ │ └── web
│ │ └── TestController.java
└── pom.xml
├── diagram-uml
├── BusEndPoint.uml
├── EurekaDiscoveryClient.uml
├── BusEvent.uml
├── BusListener.uml
└── BusEventAndListener.uml
├── turbine
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── TurbineApplication.java
└── pom.xml
├── ribbon-consumer
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── web
│ │ ├── ConsumerController.java
│ │ ├── User.java
│ │ └── HelloService.java
│ │ └── ConsumerApplication.java
└── pom.xml
├── config-client-eureka
├── src
│ └── main
│ │ ├── resources
│ │ └── bootstrap.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── Application.java
│ │ └── web
│ │ └── TestController.java
└── pom.xml
├── trace-1
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── TraceApplication.java
└── pom.xml
├── zipkin-server-stream
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── ZipkinApplication.java
└── pom.xml
├── stream-producer
├── src
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── didispace
│ │ │ ├── HelloApplication.java
│ │ │ ├── User.java
│ │ │ ├── SinkSender3.java
│ │ │ ├── App2.java
│ │ │ ├── SinkSender2.java
│ │ │ ├── SinkSender4.java
│ │ │ └── SinkSender.java
│ │ └── resources
│ │ └── application.properties
└── pom.xml
├── README.md
├── trace-stream-1
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── TraceApplication.java
└── pom.xml
├── trace-stream-2
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ └── TraceApplication.java
└── pom.xml
├── stream-consumer
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── didispace
│ │ │ │ ├── HelloApplication.java
│ │ │ │ ├── SinkReceiver1.java
│ │ │ │ ├── User.java
│ │ │ │ ├── SinkReceiver4.java
│ │ │ │ ├── SinkReceiver2.java
│ │ │ │ ├── App1.java
│ │ │ │ └── SinkReceiver3.java
│ │ └── resources
│ │ │ └── application.properties
│ └── test
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── HelloApplicationTests2.java
│ │ ├── HelloApplicationTests3.java
│ │ └── HelloApplicationTests.java
└── pom.xml
├── config-client-eureka-rabbit
├── src
│ └── main
│ │ ├── resources
│ │ └── bootstrap.properties
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── Application.java
│ │ └── web
│ │ └── TestController.java
└── pom.xml
├── config-client-eureka-kafka
├── src
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── didispace
│ │ │ ├── Application.java
│ │ │ └── web
│ │ │ └── TestController.java
│ │ └── resources
│ │ └── bootstrap.properties
└── pom.xml
├── zipkin-server-stream-mysql
├── src
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── didispace
│ │ │ └── ZipkinApplication.java
│ │ └── resources
│ │ ├── application.properties
│ │ └── mysql.sql
└── pom.xml
├── hello-service-api
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── didispace
│ │ ├── service
│ │ └── HelloService.java
│ │ └── dto
│ │ └── User.java
└── pom.xml
├── stream-hello
└── src
│ └── main
│ └── java
│ └── com
│ └── didispace
│ └── aggregate
│ └── Sink
│ └── SinkApplication.java
└── pom.xml
/config-repo/didispace-dev.properties:
--------------------------------------------------------------------------------
1 | from=git-dev-3.0
--------------------------------------------------------------------------------
/config-repo/didispace-prod.properties:
--------------------------------------------------------------------------------
1 | from=git-prod-1.0
--------------------------------------------------------------------------------
/config-repo/didispace-test.properties:
--------------------------------------------------------------------------------
1 | from=git-test-1.0
--------------------------------------------------------------------------------
/config-repo/didispace.properties:
--------------------------------------------------------------------------------
1 | from=git-default-1.0
2 |
--------------------------------------------------------------------------------
/config-server-eureka/src/main/resources/didispace.properties:
--------------------------------------------------------------------------------
1 | from=local
--------------------------------------------------------------------------------
/config-server/src/main/resources/didispace-dev.properties:
--------------------------------------------------------------------------------
1 | from=local-dev
--------------------------------------------------------------------------------
/config-server/src/main/resources/didispace-prod.properties:
--------------------------------------------------------------------------------
1 | from=local-prod
--------------------------------------------------------------------------------
/config-server/src/main/resources/didispace-test.properties:
--------------------------------------------------------------------------------
1 | from=local-test
--------------------------------------------------------------------------------
/config-server-eureka-kafka/src/main/resources/didispace.properties:
--------------------------------------------------------------------------------
1 | from=local
--------------------------------------------------------------------------------
/config-server-eureka-rabbit/src/main/resources/didispace.properties:
--------------------------------------------------------------------------------
1 | from=local
--------------------------------------------------------------------------------
/config-server-eureka/src/main/resources/didispace-dev.properties:
--------------------------------------------------------------------------------
1 | from=local-dev
--------------------------------------------------------------------------------
/spring_cloud_in_action/config-repo/didispace-dev.properties:
--------------------------------------------------------------------------------
1 | from=git-dev-3.0
--------------------------------------------------------------------------------
/spring_cloud_in_action/config-repo/didispace-prod.properties:
--------------------------------------------------------------------------------
1 | from=git-prod-1.0
--------------------------------------------------------------------------------
/spring_cloud_in_action/config-repo/didispace-test.properties:
--------------------------------------------------------------------------------
1 | from=git-test-1.0
--------------------------------------------------------------------------------
/config-server-eureka/src/main/resources/didispace-prod.properties:
--------------------------------------------------------------------------------
1 | from=local-prod
--------------------------------------------------------------------------------
/config-server-eureka/src/main/resources/didispace-test.properties:
--------------------------------------------------------------------------------
1 | from=local-test
--------------------------------------------------------------------------------
/spring-boot-hello/src/main/resources/application-dev.properties:
--------------------------------------------------------------------------------
1 | server.port=8881
--------------------------------------------------------------------------------
/spring-boot-hello/src/main/resources/application-prod.properties:
--------------------------------------------------------------------------------
1 | server.port=8883
--------------------------------------------------------------------------------
/spring-boot-hello/src/main/resources/application-test.properties:
--------------------------------------------------------------------------------
1 | server.port=8882
--------------------------------------------------------------------------------
/spring_cloud_in_action/config-repo/didispace.properties:
--------------------------------------------------------------------------------
1 | from=git-default-1.0
2 |
--------------------------------------------------------------------------------
/config-server-eureka-kafka/src/main/resources/didispace-dev.properties:
--------------------------------------------------------------------------------
1 | from=local-dev
--------------------------------------------------------------------------------
/config-server-eureka-kafka/src/main/resources/didispace-prod.properties:
--------------------------------------------------------------------------------
1 | from=local-prod
--------------------------------------------------------------------------------
/config-server-eureka-kafka/src/main/resources/didispace-test.properties:
--------------------------------------------------------------------------------
1 | from=local-test
--------------------------------------------------------------------------------
/config-server-eureka-rabbit/src/main/resources/didispace-dev.properties:
--------------------------------------------------------------------------------
1 | from=local-dev
--------------------------------------------------------------------------------
/config-server-eureka-rabbit/src/main/resources/didispace-prod.properties:
--------------------------------------------------------------------------------
1 | from=local-prod
--------------------------------------------------------------------------------
/config-server-eureka-rabbit/src/main/resources/didispace-test.properties:
--------------------------------------------------------------------------------
1 | from=local-test
--------------------------------------------------------------------------------
/hystrix-dashboard/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=hystrix-dashboard
2 | server.port=2001
--------------------------------------------------------------------------------
/config-repo/api-gateway.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/config-repo/api-gateway.properties
--------------------------------------------------------------------------------
/api-gateway/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/api-gateway/src/main/resources/application.properties
--------------------------------------------------------------------------------
/config-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/config-server/src/main/resources/application.properties
--------------------------------------------------------------------------------
/config-server/src/main/resources/config-server.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/config-server/src/main/resources/config-server.keystore
--------------------------------------------------------------------------------
/eureka-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/eureka-server/src/main/resources/application.properties
--------------------------------------------------------------------------------
/feign-consumer/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/feign-consumer/src/main/resources/application.properties
--------------------------------------------------------------------------------
/hello-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/hello-service/src/main/resources/application.properties
--------------------------------------------------------------------------------
/spring-boot-hello/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/spring-boot-hello/src/main/resources/application.properties
--------------------------------------------------------------------------------
/spring_cloud_in_action/config-repo/api-gateway.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/spring_cloud_in_action/config-repo/api-gateway.properties
--------------------------------------------------------------------------------
/config-server-eureka-kafka/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/config-server-eureka-kafka/src/main/resources/application.properties
--------------------------------------------------------------------------------
/config-server-eureka-rabbit/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dyc87112/SpringCloudBook/HEAD/config-server-eureka-rabbit/src/main/resources/application.properties
--------------------------------------------------------------------------------
/zipkin-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=zipkin-server
2 | server.port=9411
3 |
4 | #eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
5 |
--------------------------------------------------------------------------------
/turbine-amqp/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=turbine-amqp
2 |
3 | server.port=7989
4 | management.port=7990
5 |
6 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
--------------------------------------------------------------------------------
/eureka-server-ha/src/main/resources/application-peer1.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=eureka-server
2 | server.port=1111
3 | eureka.instance.hostname=peer1
4 |
5 | eureka.client.serviceUrl.defaultZone=http://peer2:1112/eureka/
--------------------------------------------------------------------------------
/eureka-server-ha/src/main/resources/application-peer2.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=eureka-server
2 | server.port=1112
3 | eureka.instance.hostname=peer2
4 |
5 | eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/
--------------------------------------------------------------------------------
/rabbitmq-hello/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=rabbitmq-hello
2 |
3 | spring.rabbitmq.host=localhost
4 | spring.rabbitmq.port=5672
5 | spring.rabbitmq.username=springcloud
6 | spring.rabbitmq.password=123456
7 |
--------------------------------------------------------------------------------
/eureka-server-ha/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=1111
2 | eureka.instance.hostname=localhost
3 |
4 | eureka.client.register-with-eureka=false
5 | eureka.client.fetch-registry=false
6 | eureka.client.serviceUrl.defaultZone=http://localhost:${server.port}/eureka/
--------------------------------------------------------------------------------
/api-gateway-dynamic-route/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=api-gateway
2 | server.port=5556
3 |
4 | #spring.cloud.config.profile=dev
5 | spring.cloud.config.uri=http://localhost:7001/
6 |
7 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
--------------------------------------------------------------------------------
/api-gateway-dynamic-filter/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=api-gateway
2 | server.port=5555
3 |
4 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
5 |
6 | zuul.filter.root=filter
7 | zuul.filter.interval=5
8 |
9 | #zuul.debug.request=true
10 |
--------------------------------------------------------------------------------
/api-gateway-exception/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=api-gateway
2 | server.port=5555
3 |
4 | # eureka
5 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
6 |
7 | #zuul.ThrowExceptionFilter.pre.disable=true
8 | zuul.ThrowExceptionPostFilter.post.disable=true
9 |
--------------------------------------------------------------------------------
/feign-consumer/src/main/java/com/didispace/web/RefactorHelloService.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.springframework.cloud.netflix.feign.FeignClient;
4 |
5 | @FeignClient(value = "HELLO-SERVICE")
6 | public interface RefactorHelloService extends com.didispace.service.HelloService {
7 |
8 |
9 | }
--------------------------------------------------------------------------------
/trace-2/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
2 |
3 | spring.zipkin.base-url=http://localhost:9411
4 |
5 | spring.sleuth.sampler.percentage=0.1
6 |
7 | # log trace detail
8 | logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG
--------------------------------------------------------------------------------
/config-client/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=didispace
2 |
3 | spring.cloud.config.profile=dev
4 | spring.cloud.config.uri=http://localhost:7001/
5 | #spring.cloud.config.username=user
6 | #spring.cloud.config.password=37cc5635-559b-4e6f-b633-7e932b813f73
7 |
8 | server.port=7002
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/diagram-uml/BusEndPoint.uml:
--------------------------------------------------------------------------------
1 |
2 |
3 | JAVA
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | All
12 |
13 |
14 |
--------------------------------------------------------------------------------
/turbine/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=turbine
2 |
3 | server.port=8989
4 | management.port=8990
5 |
6 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
7 |
8 | turbine.app-config=RIBBON-CONSUMER,RIBBON-CONSUMER-2
9 | turbine.cluster-name-expression="default"
10 | turbine.combine-host-port=true
--------------------------------------------------------------------------------
/ribbon-consumer/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=ribbon-consumer
2 | server.port=9000
3 |
4 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
5 |
6 | #hystrix.command.helloKey.execution.isolation.thread.timeoutInMilliseconds=5000
7 | hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=2000
--------------------------------------------------------------------------------
/config-client-eureka/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=didispace
2 | server.port=7002
3 |
4 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
5 |
6 | spring.cloud.config.discovery.enabled=true
7 | spring.cloud.config.discovery.serviceId=config-server
8 | spring.cloud.config.profile=dev
9 |
10 | spring.cloud.config.failFast=true
--------------------------------------------------------------------------------
/trace-1/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=trace-1
2 | server.port=9101
3 |
4 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
5 |
6 | spring.zipkin.base-url=http://localhost:9411
7 |
8 | spring.sleuth.sampler.percentage=0.1
9 |
10 | # log trace detail
11 | logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG
--------------------------------------------------------------------------------
/zipkin-server-stream/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=zipkin-server-stream
2 | server.port=9411
3 |
4 | spring.rabbitmq.host=localhost
5 | spring.rabbitmq.port=5672
6 | spring.rabbitmq.username=springcloud
7 | spring.rabbitmq.password=123456
8 |
9 | #eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
10 |
11 | logging.file=${spring.application.name}.log
--------------------------------------------------------------------------------
/spring-boot-hello/src/main/java/com/didispace/web/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.springframework.web.bind.annotation.RequestMapping;
4 | import org.springframework.web.bind.annotation.RestController;
5 |
6 | @RestController
7 | public class HelloController {
8 |
9 | @RequestMapping("/hello")
10 | public String index() {
11 | return "Hello World";
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/spring-boot-hello/src/main/java/com/didispace/HelloApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class HelloApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(HelloApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/rabbitmq-hello/src/main/java/com/didispace/HelloApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class HelloApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(HelloApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/stream-producer/src/main/java/com/didispace/HelloApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class HelloApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(HelloApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/api-gateway/src/main/java/com/didispace/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.web.bind.annotation.RequestMapping;
4 | import org.springframework.web.bind.annotation.RestController;
5 |
6 |
7 | @RestController
8 | public class HelloController {
9 |
10 | @RequestMapping("/local/hello")
11 | public String hello() {
12 | return "Hello World Local";
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/config-client/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 |
6 | @SpringBootApplication
7 | public class Application {
8 |
9 | public static void main(String[] args) {
10 | new SpringApplicationBuilder(Application.class).web(true).run(args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/config-server/src/main/resources/didispace.properties:
--------------------------------------------------------------------------------
1 | from=local
2 | #from={cipher}AQBL4zN73nFahuirqUyWjgMD3o7FJJstbVKWfrSqh9k4V/GiS9osQRl0U17xsBX5nciFvm1XcfnB1tD13Hg3OCZds9tNS7NSixED4Kx7Bgq5vIuTzZpZkVb5YYvJyjFUhHnvdeTfgblsSS2a1NTABZ19n6quYnaupLdONKsa6goqagbg9FFwdvjLx0dWKfDsAF74lO9qYuCNsR2oJiDwvWnry3r3x8ewvXb6u0LxZ9DXGWPRsLITTY7BRkuwt3bra93gj4Elp4r1JFMwgAt6EbdF+7mXxVO51MPn9xvRKZPgpkk+e40t8Y/YjJ2P4SwzdbzMLuKbOwq2+MbWa37eyUt+f9BZ2GCFDHQPKDNIP3dWo4vuO0mja19osiWYUkOufcs=
--------------------------------------------------------------------------------
/zipkin-server/src/main/java/com/didispace/ZipkinApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import zipkin.server.EnableZipkinServer;
6 |
7 | @EnableZipkinServer
8 | @SpringBootApplication
9 | public class ZipkinApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(ZipkinApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/config-server-eureka/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=config-server
2 | server.port=7001
3 |
4 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
5 |
6 | # git¹ÜÀíÅäÖÃ
7 | spring.cloud.config.server.git.uri=http://git.oschina.net/didispace/SpringCloud-Learning/
8 | spring.cloud.config.server.git.searchPaths=spring_cloud_in_action/config-repo
9 | spring.cloud.config.server.git.username=username
10 | spring.cloud.config.server.git.password=password
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SpringCloudBook
2 |
3 | 本工程为《Spring Cloud实战》一书的配套示例代码。如果读者在阅读过程中发现文章内容或示例有任何问题均可以在这里给我提ISSUE。
4 |
5 | **由于Spring Cloud更新频繁,作者会在博客和公众号中持续更新相关内容**
6 |
7 | ## 博客文章
8 |
9 | - 作者博客:http://blog.didispace.com
10 | - Spring Cloud系列博文:http://blog.didispace.com/categories/Spring-Cloud/
11 | - Spring Boot系列博文:http://bbs.springcloud.com.cn/categories/Spring-Boot/
12 |
13 | ## 我的公众号
14 |
15 | 
16 |
17 |
18 |
--------------------------------------------------------------------------------
/config-server/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 |
7 | @EnableConfigServer
8 | @SpringBootApplication
9 | public class Application {
10 |
11 | public static void main(String[] args) {
12 | new SpringApplicationBuilder(Application.class).web(true).run(args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/trace-stream-1/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=trace-1
2 | server.port=9101
3 |
4 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
5 |
6 | spring.rabbitmq.host=localhost
7 | spring.rabbitmq.port=5672
8 | spring.rabbitmq.username=springcloud
9 | spring.rabbitmq.password=123456
10 |
11 | #spring.sleuth.sampler.percentage=0.1
12 |
13 | # log trace detail
14 | logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG
15 |
16 | logging.file=${spring.application.name}.log
--------------------------------------------------------------------------------
/trace-stream-2/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=trace-2
2 | server.port=9102
3 |
4 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
5 |
6 | spring.rabbitmq.host=localhost
7 | spring.rabbitmq.port=5672
8 | spring.rabbitmq.username=springcloud
9 | spring.rabbitmq.password=123456
10 |
11 | #spring.sleuth.sampler.percentage=0.1
12 |
13 | # log trace detail
14 | logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG
15 |
16 | logging.file=${spring.application.name}.log
--------------------------------------------------------------------------------
/eureka-server-ha/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class Application {
10 |
11 | public static void main(String[] args) {
12 | new SpringApplicationBuilder(Application.class).web(true).run(args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/eureka-server/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @EnableEurekaServer
8 | @SpringBootApplication
9 | public class Application {
10 |
11 | public static void main(String[] args) {
12 | new SpringApplicationBuilder(Application.class).web(true).run(args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/stream-consumer/src/main/java/com/didispace/HelloApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.messaging.converter.MessageConverter;
7 |
8 | @SpringBootApplication
9 | public class HelloApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(HelloApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/config-client-eureka-rabbit/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=didispace
2 | server.port=7002
3 |
4 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
5 |
6 | spring.cloud.config.discovery.enabled=true
7 | spring.cloud.config.discovery.serviceId=config-server
8 | spring.cloud.config.profile=dev
9 |
10 | spring.cloud.config.failFast=true
11 |
12 | # RabbitMQ
13 | spring.rabbitmq.host=localhost
14 | spring.rabbitmq.port=5672
15 | spring.rabbitmq.username=springcloud
16 | spring.rabbitmq.password=123456
--------------------------------------------------------------------------------
/config-client-eureka/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 |
7 | @EnableDiscoveryClient
8 | @SpringBootApplication
9 | public class Application {
10 |
11 | public static void main(String[] args) {
12 | new SpringApplicationBuilder(Application.class).web(true).run(args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/rabbitmq-hello/src/main/java/com/didispace/rabbit/RabbitConfig.java:
--------------------------------------------------------------------------------
1 | package com.didispace.rabbit;
2 |
3 | import org.springframework.amqp.core.Queue;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 |
7 | /**
8 | * @author 翟永超
9 | * @create 2016/9/25.
10 | * @blog http://blog.didispace.com
11 | */
12 | @Configuration
13 | public class RabbitConfig {
14 |
15 | @Bean
16 | public Queue helloQueue() {
17 | return new Queue("hello");
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/config-client-eureka-kafka/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 |
7 | @EnableDiscoveryClient
8 | @SpringBootApplication
9 | public class Application {
10 |
11 | public static void main(String[] args) {
12 | new SpringApplicationBuilder(Application.class).web(true).run(args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/config-client-eureka-rabbit/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 |
7 | @EnableDiscoveryClient
8 | @SpringBootApplication
9 | public class Application {
10 |
11 | public static void main(String[] args) {
12 | new SpringApplicationBuilder(Application.class).web(true).run(args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/config-client-eureka-kafka/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=didispace
2 | server.port=7002
3 |
4 | eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
5 |
6 | spring.cloud.config.discovery.enabled=true
7 | spring.cloud.config.discovery.serviceId=config-server
8 | spring.cloud.config.profile=dev
9 |
10 | spring.cloud.config.failFast=true
11 |
12 | #kafka
13 | spring.cloud.stream.kafka.binder.zk-nodes=localhost:2181
14 | spring.cloud.stream.kafka.binder.brokers=localhost:9092
15 |
16 | spring.cloud.bus.trace.enabled=true
--------------------------------------------------------------------------------
/hystrix-dashboard/src/main/java/com/didispace/HystrixDashboardApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.cloud.client.SpringCloudApplication;
5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
6 |
7 | @EnableHystrixDashboard
8 | @SpringCloudApplication
9 | public class HystrixDashboardApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(HystrixDashboardApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/hello-service/src/main/java/com/didispace/HelloApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.netflix.hystrix.EnableHystrix;
7 |
8 | @EnableHystrix
9 | @EnableDiscoveryClient
10 | @SpringBootApplication
11 | public class HelloApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(HelloApplication.class, args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/config-server-eureka/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.config.server.EnableConfigServer;
7 |
8 | @EnableDiscoveryClient
9 | @EnableConfigServer
10 | @SpringBootApplication
11 | public class Application {
12 |
13 | public static void main(String[] args) {
14 | new SpringApplicationBuilder(Application.class).web(true).run(args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/config-server-eureka-kafka/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.config.server.EnableConfigServer;
7 |
8 | @EnableDiscoveryClient
9 | @EnableConfigServer
10 | @SpringBootApplication
11 | public class Application {
12 |
13 | public static void main(String[] args) {
14 | new SpringApplicationBuilder(Application.class).web(true).run(args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/config-server-eureka-rabbit/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.config.server.EnableConfigServer;
7 |
8 | @EnableDiscoveryClient
9 | @EnableConfigServer
10 | @SpringBootApplication
11 | public class Application {
12 |
13 | public static void main(String[] args) {
14 | new SpringApplicationBuilder(Application.class).web(true).run(args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/ribbon-consumer/src/main/java/com/didispace/web/ConsumerController.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RequestMethod;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | @RestController
9 | public class ConsumerController {
10 |
11 | @Autowired
12 | HelloService helloService;
13 |
14 | @RequestMapping(value = "/ribbon-consumer", method = RequestMethod.GET)
15 | public String helloConsumer() {
16 | return helloService.hello();
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/rabbitmq-hello/src/main/java/com/didispace/rabbit/Sender.java:
--------------------------------------------------------------------------------
1 | package com.didispace.rabbit;
2 |
3 | import org.springframework.amqp.core.AmqpTemplate;
4 | import org.springframework.amqp.rabbit.core.RabbitTemplate;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Component;
7 |
8 | import java.util.Date;
9 |
10 | @Component
11 | public class Sender {
12 |
13 | @Autowired
14 | private AmqpTemplate rabbitTemplate;
15 |
16 | public void send() {
17 | String context = "hello " + new Date();
18 | System.out.println("Sender : " + context);
19 | this.rabbitTemplate.convertAndSend("hello", context);
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/zipkin-server-stream/src/main/java/com/didispace/ZipkinApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.sleuth.zipkin.stream.EnableZipkinStreamServer;
6 | import org.springframework.context.annotation.Bean;
7 | import zipkin.server.EnableZipkinServer;
8 | import zipkin.storage.SpanStore;
9 |
10 | @EnableZipkinStreamServer
11 | @SpringBootApplication
12 | public class ZipkinApplication {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(ZipkinApplication.class, args);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/zipkin-server-stream-mysql/src/main/java/com/didispace/ZipkinApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.sleuth.zipkin.stream.EnableZipkinStreamServer;
6 | import org.springframework.context.annotation.Bean;
7 | import zipkin.server.EnableZipkinServer;
8 | import zipkin.storage.SpanStore;
9 |
10 | @EnableZipkinStreamServer
11 | @SpringBootApplication
12 | public class ZipkinApplication {
13 |
14 | public static void main(String[] args) {
15 | SpringApplication.run(ZipkinApplication.class, args);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/turbine/src/main/java/com/didispace/TurbineApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.netflix.turbine.EnableTurbine;
7 | import org.springframework.context.annotation.Configuration;
8 |
9 | @Configuration
10 | @EnableAutoConfiguration
11 | @EnableTurbine
12 | @EnableDiscoveryClient
13 | public class TurbineApplication {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(TurbineApplication.class, args);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/hello-service-api/src/main/java/com/didispace/service/HelloService.java:
--------------------------------------------------------------------------------
1 | package com.didispace.service;
2 |
3 | import com.didispace.dto.User;
4 | import org.springframework.web.bind.annotation.*;
5 |
6 | @RequestMapping("/refactor")
7 | public interface HelloService {
8 |
9 | @RequestMapping(value = "/hello4", method = RequestMethod.GET)
10 | String hello(@RequestParam("name") String name) ;
11 |
12 | @RequestMapping(value = "/hello5", method = RequestMethod.GET)
13 | User hello(@RequestHeader("name") String name, @RequestHeader("age") Integer age);
14 |
15 | @RequestMapping(value = "/hello6", method = RequestMethod.POST)
16 | String hello(@RequestBody User user);
17 |
18 | }
--------------------------------------------------------------------------------
/turbine-amqp/src/main/java/com/didispace/TurbineApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.netflix.turbine.stream.EnableTurbineStream;
7 | import org.springframework.context.annotation.Configuration;
8 |
9 | @Configuration
10 | @EnableAutoConfiguration
11 | @EnableTurbineStream
12 | @EnableDiscoveryClient
13 | public class TurbineApplication {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(TurbineApplication.class, args);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/rabbitmq-hello/src/main/java/com/didispace/rabbit/Receiver.java:
--------------------------------------------------------------------------------
1 | package com.didispace.rabbit;
2 |
3 | import org.springframework.amqp.rabbit.annotation.RabbitHandler;
4 | import org.springframework.amqp.rabbit.annotation.RabbitListener;
5 | import org.springframework.cache.annotation.Cacheable;
6 | import org.springframework.stereotype.Component;
7 |
8 | import java.util.Date;
9 |
10 | /**
11 | * @author 翟永超
12 | * @create 2016/9/25.
13 | * @blog http://blog.didispace.com
14 | */
15 | @Component
16 | @RabbitListener(queues = "hello")
17 | public class Receiver {
18 |
19 | @RabbitHandler
20 | public void process(String hello) {
21 | System.out.println("Receiver : " + hello);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/rabbitmq-hello/src/test/java/com/didispace/HelloApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import com.didispace.rabbit.Sender;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
9 |
10 | @RunWith(SpringJUnit4ClassRunner.class)
11 | @SpringApplicationConfiguration(classes = HelloApplication.class)
12 | public class HelloApplicationTests {
13 |
14 | @Autowired
15 | private Sender sender;
16 |
17 | @Test
18 | public void hello() throws Exception {
19 | sender.send();
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/hello-service/src/main/java/com/didispace/web/RefactorHelloController.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import com.didispace.dto.User;
4 | import com.didispace.service.HelloService;
5 | import org.springframework.web.bind.annotation.*;
6 |
7 | @RestController
8 | public class RefactorHelloController implements HelloService {
9 |
10 | @Override
11 | public String hello(@RequestParam("name") String name) {
12 | return "Hello " + name;
13 | }
14 |
15 | @Override
16 | public User hello(@RequestHeader("name") String name, @RequestHeader("age") Integer age) {
17 | return new User(name, age);
18 | }
19 |
20 | @Override
21 | public String hello(@RequestBody User user) {
22 | return "Hello "+ user.getName() + ", " + user.getAge();
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/hello-service/src/main/java/com/didispace/indicator/RocketMQHealthIndicator.java:
--------------------------------------------------------------------------------
1 | package com.didispace.indicator;
2 |
3 | import org.springframework.boot.actuate.health.Health;
4 | import org.springframework.boot.actuate.health.HealthIndicator;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | public class RocketMQHealthIndicator implements HealthIndicator {
9 |
10 | @Override
11 | public Health health() {
12 | int errorCode = check();
13 | if (errorCode != 0) {
14 | return Health.down().withDetail("Error Code", errorCode).build();
15 | }
16 | return Health.up().build();
17 | }
18 |
19 | private int check() {
20 | // perform some specific health check
21 | return 0;
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/config-client/src/main/java/com/didispace/web/TestController.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.cloud.context.config.annotation.RefreshScope;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | @RefreshScope
9 | @RestController
10 | public class TestController {
11 |
12 | @Value("${from}")
13 | private String from;
14 |
15 | @RequestMapping("/from")
16 | public String from() {
17 | return this.from;
18 | }
19 |
20 | public void setFrom(String from) {
21 | this.from = from;
22 | }
23 |
24 | public String getFrom() {
25 | return from;
26 | }
27 |
28 | }
--------------------------------------------------------------------------------
/config-client-eureka/src/main/java/com/didispace/web/TestController.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.cloud.context.config.annotation.RefreshScope;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | @RefreshScope
9 | @RestController
10 | public class TestController {
11 |
12 | @Value("${from}")
13 | private String from;
14 |
15 | @RequestMapping("/from")
16 | public String from() {
17 | return this.from;
18 | }
19 |
20 | public void setFrom(String from) {
21 | this.from = from;
22 | }
23 |
24 | public String getFrom() {
25 | return from;
26 | }
27 |
28 | }
--------------------------------------------------------------------------------
/config-client-eureka-kafka/src/main/java/com/didispace/web/TestController.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.cloud.context.config.annotation.RefreshScope;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | @RefreshScope
9 | @RestController
10 | public class TestController {
11 |
12 | @Value("${from}")
13 | private String from;
14 |
15 | @RequestMapping("/from")
16 | public String from() {
17 | return this.from;
18 | }
19 |
20 | public void setFrom(String from) {
21 | this.from = from;
22 | }
23 |
24 | public String getFrom() {
25 | return from;
26 | }
27 |
28 | }
--------------------------------------------------------------------------------
/config-client-eureka-rabbit/src/main/java/com/didispace/web/TestController.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.cloud.context.config.annotation.RefreshScope;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | @RefreshScope
9 | @RestController
10 | public class TestController {
11 |
12 | @Value("${from}")
13 | private String from;
14 |
15 | @RequestMapping("/from")
16 | public String from() {
17 | return this.from;
18 | }
19 |
20 | public void setFrom(String from) {
21 | this.from = from;
22 | }
23 |
24 | public String getFrom() {
25 | return from;
26 | }
27 |
28 | }
--------------------------------------------------------------------------------
/api-gateway-dynamic-filter/src/main/java/com/didispace/FilterConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.context.properties.ConfigurationProperties;
4 |
5 | /**
6 | * @author 翟永超
7 | * @create 2016/12/11.
8 | * @blog http://blog.didispace.com
9 | */
10 | @ConfigurationProperties("zuul.filter")
11 | public class FilterConfiguration {
12 |
13 | private String root;
14 | private Integer interval;
15 |
16 | public String getRoot() {
17 | return root;
18 | }
19 |
20 | public void setRoot(String root) {
21 | this.root = root;
22 | }
23 |
24 | public Integer getInterval() {
25 | return interval;
26 | }
27 |
28 | public void setInterval(Integer interval) {
29 | this.interval = interval;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/feign-consumer/src/main/java/com/didispace/ConsumerApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import feign.Logger;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.cloud.netflix.feign.EnableFeignClients;
8 | import org.springframework.context.annotation.Bean;
9 |
10 | @EnableFeignClients
11 | @EnableDiscoveryClient
12 | @SpringBootApplication
13 | public class ConsumerApplication {
14 |
15 | // @Bean
16 | // Logger.Level feignLoggerLevel() {
17 | // return Logger.Level.FULL;
18 | // }
19 |
20 | public static void main(String[] args) {
21 | SpringApplication.run(ConsumerApplication.class, args);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/stream-consumer/src/main/java/com/didispace/SinkReceiver1.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.cloud.stream.annotation.EnableBinding;
6 | import org.springframework.cloud.stream.annotation.StreamListener;
7 | import org.springframework.cloud.stream.messaging.Sink;
8 |
9 | /**
10 | * 快速入门
11 | *
12 | * @author 翟永超
13 | * @create 2016/11/8.
14 | * @blog http://blog.didispace.com
15 | */
16 | //@EnableBinding(value = {Sink.class})
17 | public class SinkReceiver1 {
18 |
19 | private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);
20 |
21 | @StreamListener(Sink.INPUT)
22 | public void receive(Object payload) {
23 | logger.info("Received: " + payload);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/stream-hello/src/main/java/com/didispace/aggregate/Sink/SinkApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace.aggregate.Sink;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.stream.annotation.EnableBinding;
7 | import org.springframework.cloud.stream.messaging.Sink;
8 | import org.springframework.integration.annotation.ServiceActivator;
9 |
10 | @SpringBootApplication
11 | @EnableBinding(Sink.class)
12 | public class SinkApplication {
13 |
14 | private static Logger logger = LoggerFactory.getLogger(SinkApplication.class);
15 |
16 | @ServiceActivator(inputChannel=Sink.INPUT)
17 | public void loggerSink(Object payload) {
18 | logger.info("Received: " + payload);
19 | }
20 | }
--------------------------------------------------------------------------------
/api-gateway-exception/src/main/java/com/didispace/filter/DidiErrorAttributes.java:
--------------------------------------------------------------------------------
1 | package com.didispace.filter;
2 |
3 | import org.springframework.boot.autoconfigure.web.DefaultErrorAttributes;
4 | import org.springframework.web.context.request.RequestAttributes;
5 |
6 | import java.util.Map;
7 |
8 | /**
9 | * @author 翟永超
10 | * @create 2016/12/15.
11 | * @blog http://blog.didispace.com
12 | */
13 | public class DidiErrorAttributes extends DefaultErrorAttributes {
14 |
15 | @Override
16 | public Map getErrorAttributes (
17 | RequestAttributes requestAttributes, boolean includeStackTrace){
18 | Map result = super.getErrorAttributes(requestAttributes, includeStackTrace);
19 | result.remove("exception");
20 | return result;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/feign-consumer/src/main/java/com/didispace/web/HelloService.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.springframework.cloud.netflix.feign.FeignClient;
4 | import org.springframework.web.bind.annotation.*;
5 |
6 | @FeignClient(name="HELLO-SERVICE", fallback = HelloServiceFallback.class)
7 | public interface HelloService {
8 |
9 | @RequestMapping("/hello")
10 | String hello();
11 |
12 | @RequestMapping(value = "/hello1", method = RequestMethod.GET)
13 | String hello(@RequestParam("name") String name) ;
14 |
15 | @RequestMapping(value = "/hello2", method = RequestMethod.GET)
16 | User hello(@RequestHeader("name") String name, @RequestHeader("age") Integer age);
17 |
18 | @RequestMapping(value = "/hello3", method = RequestMethod.POST)
19 | String hello(@RequestBody User user);
20 |
21 | }
--------------------------------------------------------------------------------
/feign-consumer/src/main/java/com/didispace/web/User.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | /**
4 | * Created by Administrator on 2016/9/16.
5 | */
6 | public class User {
7 |
8 | private String name;
9 | private Integer age;
10 |
11 | public User() {}
12 |
13 | public User(String name, Integer age) {
14 | this.name = name;
15 | this.age = age;
16 | }
17 |
18 | public String getName() {
19 | return name;
20 | }
21 |
22 | public void setName(String name) {
23 | this.name = name;
24 | }
25 |
26 | public Integer getAge() {
27 | return age;
28 | }
29 |
30 | public void setAge(Integer age) {
31 | this.age = age;
32 | }
33 |
34 | @Override
35 | public String toString() {
36 | return "name=" + name + ", age=" +age;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/zipkin-server-stream-mysql/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=zipkin-server-stream
2 | server.port=9411
3 |
4 | spring.rabbitmq.host=localhost
5 | spring.rabbitmq.port=5672
6 | spring.rabbitmq.username=springcloud
7 | spring.rabbitmq.password=123456
8 |
9 | spring.datasource.schema=classpath:/mysql.sql
10 | spring.datasource.url=jdbc:mysql://localhost:3306/zipkin
11 | spring.datasource.username=root
12 | spring.datasource.password=123456
13 | spring.datasrouce.continueOnError=true
14 | spring.datasrouce.initialize=true
15 | #spring.datasource.driver-class-name=com.mysql.jdbc.Driver
16 |
17 | #spring.sleuth.enabled=false
18 |
19 | zipkin.storage.type=mysql
20 | #zipkin.storage.type.mysql.username=root
21 | #zipkin.storage.type.mysql.password=123456
22 | #eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
23 |
24 |
--------------------------------------------------------------------------------
/hello-service/src/main/java/com/didispace/web/User.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | /**
4 | * Created by Administrator on 2016/9/16.
5 | */
6 | public class User {
7 |
8 | private String name;
9 | private Integer age;
10 |
11 | public User() {
12 | }
13 |
14 | public User(String name, Integer age) {
15 | this.name = name;
16 | this.age = age;
17 | }
18 |
19 | public String getName() {
20 | return name;
21 | }
22 |
23 | public void setName(String name) {
24 | this.name = name;
25 | }
26 |
27 | public Integer getAge() {
28 | return age;
29 | }
30 |
31 | public void setAge(Integer age) {
32 | this.age = age;
33 | }
34 |
35 | @Override
36 | public String toString() {
37 | return "name=" + name + ", age=" +age;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/ribbon-consumer/src/main/java/com/didispace/web/User.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | /**
4 | * Created by Administrator on 2016/9/16.
5 | */
6 | public class User {
7 |
8 | private String name;
9 | private Integer age;
10 |
11 | public User() {
12 | }
13 |
14 | public User(String name, Integer age) {
15 | this.name = name;
16 | this.age = age;
17 | }
18 |
19 | public String getName() {
20 | return name;
21 | }
22 |
23 | public void setName(String name) {
24 | this.name = name;
25 | }
26 |
27 | public Integer getAge() {
28 | return age;
29 | }
30 |
31 | public void setAge(Integer age) {
32 | this.age = age;
33 | }
34 |
35 | @Override
36 | public String toString() {
37 | return "name=" + name + ", age=" +age;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/hello-service-api/src/main/java/com/didispace/dto/User.java:
--------------------------------------------------------------------------------
1 | package com.didispace.dto;
2 |
3 | /**
4 | * Created by Administrator on 2016/9/16.
5 | */
6 | public class User {
7 |
8 | private String name;
9 | private Integer age;
10 |
11 | public User() {
12 | }
13 |
14 | public User(String name, Integer age) {
15 | this.name = name;
16 | this.age = age;
17 | }
18 |
19 | public String getName() {
20 | return name;
21 | }
22 |
23 | public void setName(String name) {
24 | this.name = name;
25 | }
26 |
27 | public Integer getAge() {
28 | return age;
29 | }
30 |
31 | public void setAge(Integer age) {
32 | this.age = age;
33 | }
34 |
35 | @Override
36 | public String toString() {
37 | return "name=" + name + ", age=" +age;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/stream-producer/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=rabbitmq-hello-2
2 | server.port=8002
3 |
4 | # Topic
5 | #spring.cloud.stream.bindings.input.destination=output
6 | #spring.cloud.stream.bindings.output.destination=input
7 | spring.cloud.stream.bindings.input.content-type=application/json
8 | spring.cloud.stream.bindings.output.content-type=application/json
9 |
10 | # RabbitMQ
11 | #spring.rabbitmq.host=localhost
12 | #spring.rabbitmq.port=5672
13 | #spring.rabbitmq.username=springcloud
14 | #spring.rabbitmq.password=123456
15 |
16 | # Comsumer Group:input
17 | #spring.cloud.stream.bindings.input.group=Service-A
18 |
19 | # Partition
20 | spring.cloud.stream.bindings.output.destination=greetings
21 | spring.cloud.stream.bindings.output.producer.partitionKeyExpression=payload
22 | spring.cloud.stream.bindings.output.producer.partitionCount=2
23 |
--------------------------------------------------------------------------------
/api-gateway-exception/src/main/java/com/didispace/filter/DidiFilterProcessor.java:
--------------------------------------------------------------------------------
1 | package com.didispace.filter;
2 |
3 | import com.netflix.zuul.FilterProcessor;
4 | import com.netflix.zuul.ZuulFilter;
5 | import com.netflix.zuul.context.RequestContext;
6 | import com.netflix.zuul.exception.ZuulException;
7 |
8 | /**
9 | * @author 翟永超
10 | * @create 2016/12/15.
11 | * @blog http://blog.didispace.com
12 | */
13 | public class DidiFilterProcessor extends FilterProcessor {
14 |
15 | @Override
16 | public Object processZuulFilter(ZuulFilter filter) throws ZuulException {
17 | try {
18 | return super.processZuulFilter(filter);
19 | } catch (ZuulException e) {
20 | RequestContext ctx = RequestContext.getCurrentContext();
21 | ctx.set("failed.exception", e);
22 | ctx.set("failed.filter", filter);
23 | throw e;
24 | }
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/ribbon-consumer/src/main/java/com/didispace/ConsumerApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.web.client.RestTemplate;
10 |
11 | @EnableCircuitBreaker
12 | @EnableDiscoveryClient
13 | @SpringBootApplication
14 | public class ConsumerApplication {
15 |
16 | @Bean
17 | @LoadBalanced
18 | RestTemplate restTemplate() {
19 | return new RestTemplate();
20 | }
21 | public static void main(String[] args) {
22 | SpringApplication.run(ConsumerApplication.class, args);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/api-gateway-dynamic-filter/filter/pre/PreFilter.groovy:
--------------------------------------------------------------------------------
1 | package com.didispace.filter.pre
2 |
3 | import org.slf4j.Logger
4 | import org.slf4j.LoggerFactory;
5 |
6 | import javax.servlet.http.HttpServletRequest;
7 |
8 | import com.netflix.zuul.ZuulFilter;
9 | import com.netflix.zuul.context.RequestContext;
10 |
11 | class PreFilter extends ZuulFilter {
12 |
13 | Logger log = LoggerFactory.getLogger(PreFilter.class)
14 |
15 | @Override
16 | String filterType() {
17 | return "pre"
18 | }
19 |
20 | @Override
21 | int filterOrder() {
22 | return 1000
23 | }
24 |
25 | @Override
26 | boolean shouldFilter() {
27 | return true
28 | }
29 |
30 | @Override
31 | Object run() {
32 | HttpServletRequest request = RequestContext.getCurrentContext().getRequest()
33 | log.info("this is a pre filter: Send {} request to {}", request.getMethod(), request.getRequestURL().toString())
34 | return null
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/stream-consumer/src/main/java/com/didispace/User.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * @author 翟永超
7 | * @create 2016/11/13.
8 | * @blog http://blog.didispace.com
9 | */
10 | public class User implements Serializable {
11 |
12 | private String name;
13 | private Integer age;
14 |
15 | public User() {
16 |
17 | }
18 |
19 | public User(String name, Integer age) {
20 | this.name = name;
21 | this.age = age;
22 | }
23 |
24 | public String getName() {
25 | return name;
26 | }
27 |
28 | public void setName(String name) {
29 | this.name = name;
30 | }
31 |
32 | public Integer getAge() {
33 | return age;
34 | }
35 |
36 | public void setAge(Integer age) {
37 | this.age = age;
38 | }
39 |
40 | @Override
41 | public String toString() {
42 | return "name=" + name + ", age=" + age;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/stream-producer/src/main/java/com/didispace/User.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * @author 翟永超
7 | * @create 2016/11/13.
8 | * @blog http://blog.didispace.com
9 | */
10 | public class User implements Serializable {
11 |
12 | private String name;
13 | private Integer age;
14 |
15 | public User() {
16 |
17 | }
18 |
19 | public User(String name, Integer age) {
20 | this.name = name;
21 | this.age = age;
22 | }
23 |
24 | public String getName() {
25 | return name;
26 | }
27 |
28 | public void setName(String name) {
29 | this.name = name;
30 | }
31 |
32 | public Integer getAge() {
33 | return age;
34 | }
35 |
36 | public void setAge(Integer age) {
37 | this.age = age;
38 | }
39 |
40 | @Override
41 | public String toString() {
42 | return "name=" + name + ", age=" + age;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/api-gateway-dynamic-route/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.springframework.boot.builder.SpringApplicationBuilder;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 | import org.springframework.cloud.client.SpringCloudApplication;
6 | import org.springframework.cloud.context.config.annotation.RefreshScope;
7 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
8 | import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
9 | import org.springframework.context.annotation.Bean;
10 |
11 | @EnableZuulProxy
12 | @SpringCloudApplication
13 | public class Application {
14 |
15 | public static void main(String[] args) {
16 | new SpringApplicationBuilder(Application.class).web(true).run(args);
17 | }
18 |
19 | @Bean
20 | @RefreshScope
21 | @ConfigurationProperties("zuul")
22 | public ZuulProperties zuulProperties() {
23 | return new ZuulProperties();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/api-gateway-exception/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import com.didispace.filter.DidiErrorAttributes;
4 | import com.didispace.filter.DidiFilterProcessor;
5 | import com.netflix.zuul.FilterProcessor;
6 | import org.springframework.boot.autoconfigure.web.DefaultErrorAttributes;
7 | import org.springframework.boot.builder.SpringApplicationBuilder;
8 | import org.springframework.cloud.client.SpringCloudApplication;
9 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
10 | import org.springframework.context.annotation.Bean;
11 |
12 | @EnableZuulProxy
13 | @SpringCloudApplication
14 | public class Application {
15 |
16 | public static void main(String[] args) {
17 | FilterProcessor.setProcessor(new DidiFilterProcessor());
18 | new SpringApplicationBuilder(Application.class).web(true).run(args);
19 | }
20 |
21 | @Bean
22 | public DefaultErrorAttributes errorAttributes() {
23 | return new DidiErrorAttributes();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/api-gateway/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import com.didispace.filter.AccessFilter;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cloud.client.SpringCloudApplication;
6 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
7 | import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
8 | import org.springframework.context.annotation.Bean;
9 |
10 | @EnableZuulProxy
11 | @SpringCloudApplication
12 | public class Application {
13 |
14 | public static void main(String[] args) {
15 | new SpringApplicationBuilder(Application.class).web(true).run(args);
16 | }
17 |
18 | @Bean
19 | public AccessFilter accessFilter() {
20 | return new AccessFilter();
21 | }
22 |
23 | @Bean
24 | public PatternServiceRouteMapper serviceRouteMapper() {
25 | return new PatternServiceRouteMapper(
26 | "(?^.+)-(?v.+$)",
27 | "${version}/${name}");
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/feign-consumer/src/main/java/com/didispace/web/HelloServiceFallback.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.springframework.stereotype.Component;
4 | import org.springframework.web.bind.annotation.RequestBody;
5 | import org.springframework.web.bind.annotation.RequestHeader;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 |
8 | /**
9 | * Created by Administrator on 2016/9/16.
10 | */
11 | @Component
12 | public class HelloServiceFallback implements HelloService {
13 |
14 | @Override
15 | public String hello() {
16 | return "error";
17 | }
18 |
19 | @Override
20 | public String hello(@RequestParam("name") String name) {
21 | return "error";
22 | }
23 |
24 | @Override
25 | public User hello(@RequestHeader("name") String name, @RequestHeader("age") Integer age) {
26 | return new User("未知", 0);
27 | }
28 |
29 | @Override
30 | public String hello(@RequestBody User user) {
31 | return "error";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/stream-consumer/src/test/java/com/didispace/HelloApplicationTests2.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.beans.factory.annotation.Qualifier;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.integration.support.MessageBuilder;
9 | import org.springframework.messaging.MessageChannel;
10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
11 | import org.springframework.test.context.web.WebAppConfiguration;
12 |
13 | @RunWith(SpringJUnit4ClassRunner.class)
14 | @SpringApplicationConfiguration(classes = HelloApplication.class)
15 | @WebAppConfiguration
16 | //@DirtiesContext
17 | public class HelloApplicationTests2 {
18 |
19 | @Autowired @Qualifier("input")
20 | private MessageChannel output;
21 |
22 | @Test
23 | public void contextLoads() {
24 | output.send(MessageBuilder.withPayload("From MessageChannel").build());
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/api-gateway-exception/src/main/java/com/didispace/filter/post/ThrowExceptionPostFilter.java:
--------------------------------------------------------------------------------
1 | package com.didispace.filter.post;
2 |
3 | import com.netflix.zuul.ZuulFilter;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 | import org.springframework.stereotype.Component;
7 |
8 | @Component
9 | public class ThrowExceptionPostFilter extends ZuulFilter {
10 |
11 | private static Logger log = LoggerFactory.getLogger(ThrowExceptionPostFilter.class);
12 |
13 | @Override
14 | public String filterType() {
15 | return "post";
16 | }
17 |
18 | @Override
19 | public int filterOrder() {
20 | return 10;
21 | }
22 |
23 | @Override
24 | public boolean shouldFilter() {
25 | return true;
26 | }
27 |
28 | @Override
29 | public Object run() {
30 | log.info("This is a post filter, it will throw a RuntimeException");
31 | doSomething();
32 | return null;
33 | }
34 |
35 | private void doSomething() {
36 | throw new RuntimeException("Exist some errors...");
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/stream-consumer/src/test/java/com/didispace/HelloApplicationTests3.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.beans.factory.annotation.Qualifier;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.integration.support.MessageBuilder;
9 | import org.springframework.messaging.Message;
10 | import org.springframework.messaging.MessageChannel;
11 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
12 | import org.springframework.test.context.web.WebAppConfiguration;
13 |
14 | @RunWith(SpringJUnit4ClassRunner.class)
15 | @SpringApplicationConfiguration(classes = HelloApplication.class)
16 | @WebAppConfiguration
17 | //@DirtiesContext
18 | public class HelloApplicationTests3 {
19 |
20 | @Autowired @Qualifier("input")
21 | private MessageChannel output;
22 |
23 | @Test
24 | public void contextLoads() {
25 | Message message = MessageBuilder.withPayload("{\"name\":\"didi\", \"age\":30}").build();
26 | output.send(message);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/stream-consumer/src/main/java/com/didispace/SinkReceiver4.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.cloud.stream.annotation.EnableBinding;
6 | import org.springframework.cloud.stream.annotation.StreamListener;
7 | import org.springframework.cloud.stream.messaging.Sink;
8 |
9 | /**
10 | * 分区试验接收者
11 | * @author 翟永超
12 | * @create 2016/11/8.
13 | * @blog http://blog.didispace.com
14 | */
15 | @EnableBinding(value = {Sink.class})
16 | public class SinkReceiver4 {
17 |
18 | private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);
19 |
20 |
21 | @StreamListener(Sink.INPUT)
22 | public void receive(User user) {
23 | logger.info("Received: " + user);
24 | }
25 |
26 | // 配置属性如下:
27 | // # Comsumer Group:input
28 | // spring.cloud.stream.bindings.input.group=Service-A
29 | //
30 | // # Partition
31 | // spring.cloud.stream.bindings.input.destination=greetings
32 | // spring.cloud.stream.bindings.input.consumer.partitioned=true
33 | // spring.cloud.stream.instanceCount=2
34 | // spring.cloud.stream.instanceIndex=0
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/api-gateway-dynamic-filter/filter/post/PostFilter.groovy:
--------------------------------------------------------------------------------
1 | package com.didispace.filter.post
2 |
3 | import com.netflix.zuul.ZuulFilter
4 | import com.netflix.zuul.context.RequestContext
5 | import com.netflix.zuul.http.HttpServletResponseWrapper
6 | import org.slf4j.Logger
7 | import org.slf4j.LoggerFactory
8 | import org.springframework.cloud.netflix.zuul.util.RequestUtils
9 |
10 | import javax.servlet.http.HttpServletResponse
11 |
12 | class PostFilter extends ZuulFilter{
13 |
14 | Logger log = LoggerFactory.getLogger(PostFilter.class)
15 |
16 | @Override
17 | String filterType() {
18 | return "post"
19 | }
20 |
21 | @Override
22 | int filterOrder() {
23 | return 2000
24 | }
25 |
26 | @Override
27 | boolean shouldFilter() {
28 | return true
29 | }
30 |
31 | @Override
32 | Object run() {
33 | log.info("debug request : {}", RequestContext.getCurrentContext().getBoolean("debugRequest"))
34 | log.info("this is a post filter: Receive response")
35 | HttpServletResponse response = RequestContext.getCurrentContext().getResponse()
36 | response.getOutputStream().print(", I am zhaiyongchao")
37 | response.flushBuffer()
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/api-gateway-exception/src/main/java/com/didispace/filter/error/ErrorExtFilter.java:
--------------------------------------------------------------------------------
1 | package com.didispace.filter.error;
2 |
3 | import com.netflix.zuul.ZuulFilter;
4 | import com.netflix.zuul.context.RequestContext;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 | import org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter;
8 | import org.springframework.stereotype.Component;
9 |
10 | /**
11 | * 从POST抛出的异常,使用该过滤器返回错误信息
12 | */
13 | @Component
14 | public class ErrorExtFilter extends SendErrorFilter {
15 |
16 | Logger log = LoggerFactory.getLogger(ErrorExtFilter.class);
17 |
18 | @Override
19 | public String filterType() {
20 | return "error";
21 | }
22 |
23 | @Override
24 | public int filterOrder() {
25 | return 30;
26 | }
27 |
28 | @Override
29 | public boolean shouldFilter() {
30 | RequestContext ctx = RequestContext.getCurrentContext();
31 | ZuulFilter failedFilter = (ZuulFilter) ctx.get("failed.filter");
32 | if(failedFilter != null && failedFilter.filterType().equals("post")) {
33 | return true;
34 | }
35 | return false;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/hello-service-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | hello-service-api
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | hello-service-api
12 |
13 |
14 | org.springframework.boot
15 | spring-boot-starter-parent
16 | 1.3.7.RELEASE
17 |
18 |
19 |
20 |
21 | UTF-8
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-web
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/stream-consumer/src/test/java/com/didispace/HelloApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.boot.test.SpringApplicationConfiguration;
7 | import org.springframework.cloud.stream.annotation.Output;
8 | import org.springframework.integration.support.MessageBuilder;
9 | import org.springframework.messaging.MessageChannel;
10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
11 | import org.springframework.test.context.web.WebAppConfiguration;
12 |
13 | @RunWith(SpringJUnit4ClassRunner.class)
14 | @SpringApplicationConfiguration(classes = HelloApplication.class)
15 | @WebAppConfiguration
16 | //@DirtiesContext
17 | public class HelloApplicationTests {
18 |
19 | @Autowired
20 | private SinkSender sinkSender;
21 |
22 | @Test
23 | public void contextLoads() {
24 | sinkSender.output().send(MessageBuilder.withPayload("From SinkSender").build());
25 | }
26 |
27 | public interface SinkSender {
28 |
29 | String OUTPUT = "input";
30 |
31 | @Output(SinkSender.OUTPUT)
32 | MessageChannel output();
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/trace-2/src/main/java/com/didispace/TraceApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RequestMethod;
10 | import org.springframework.web.bind.annotation.RestController;
11 |
12 | import javax.servlet.http.HttpServletRequest;
13 |
14 | @RestController
15 | @EnableDiscoveryClient
16 | @SpringBootApplication
17 | public class TraceApplication {
18 |
19 | private final Logger logger = LoggerFactory.getLogger(getClass());
20 |
21 | @RequestMapping(value = "/trace-2", method = RequestMethod.GET)
22 | public String trace(HttpServletRequest request) {
23 | logger.info("======",
24 | request.getHeader("X-B3-TraceId"), request.getHeader("X-B3-SpanId"));
25 | return "Trace";
26 | }
27 |
28 | public static void main(String[] args) {
29 | SpringApplication.run(TraceApplication.class, args);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/trace-stream-2/src/main/java/com/didispace/TraceApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RequestMethod;
10 | import org.springframework.web.bind.annotation.RestController;
11 |
12 | import javax.servlet.http.HttpServletRequest;
13 |
14 | @RestController
15 | @EnableDiscoveryClient
16 | @SpringBootApplication
17 | public class TraceApplication {
18 |
19 | private final Logger logger = LoggerFactory.getLogger(getClass());
20 |
21 | @RequestMapping(value = "/trace-2", method = RequestMethod.GET)
22 | public String trace(HttpServletRequest request) {
23 | logger.info("======",
24 | request.getHeader("X-B3-TraceId"), request.getHeader("X-B3-SpanId"));
25 | return "Trace";
26 | }
27 |
28 | public static void main(String[] args) {
29 | SpringApplication.run(TraceApplication.class, args);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/stream-producer/src/main/java/com/didispace/SinkSender3.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.cloud.stream.annotation.EnableBinding;
6 | import org.springframework.cloud.stream.messaging.Processor;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.integration.annotation.InboundChannelAdapter;
9 | import org.springframework.integration.annotation.Poller;
10 | import org.springframework.integration.core.MessageSource;
11 | import org.springframework.messaging.support.GenericMessage;
12 |
13 | /**
14 | * @author 翟永超
15 | * @create 2016/11/8.
16 | * @blog http://blog.didispace.com
17 | */
18 | //@EnableBinding(value = {Processor.class})
19 | public class SinkSender3 {
20 |
21 | private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);
22 |
23 | @Bean
24 | @InboundChannelAdapter(value = Processor.OUTPUT, poller = @Poller(fixedDelay = "2000"))
25 | public MessageSource timerMessageSource() {
26 | // Map headers = new HashMap<>();
27 | // headers.put("content-type", "application/user");
28 | return () -> new GenericMessage<>("{\"name\":\"didi\", \"age\":30}");
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/stream-consumer/src/main/java/com/didispace/SinkReceiver2.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.cloud.stream.annotation.EnableBinding;
6 | import org.springframework.cloud.stream.annotation.StreamListener;
7 | import org.springframework.cloud.stream.messaging.Sink;
8 |
9 | /**
10 | * @author 翟永超
11 | * @create 2016/11/8.
12 | * @blog http://blog.didispace.com
13 | */
14 | //@EnableBinding(value = {Sink.class})
15 | public class SinkReceiver2 {
16 |
17 | private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);
18 |
19 |
20 | @StreamListener(Sink.INPUT)
21 | public void receive(User user) {
22 | logger.info("Received: " + user);
23 | }
24 |
25 | /**原生实现需要实现转换**/
26 |
27 | // @ServiceActivator(inputChannel=Sink.INPUT)
28 | // public void receive(User user) {
29 | // logger.info("Received: " + user);
30 | // }
31 | //
32 | // @Transformer(inputChannel = Sink.INPUT, outputChannel = Sink.INPUT)
33 | // public User transform(String message) throws Exception {
34 | // ObjectMapper objectMapper = new ObjectMapper();
35 | // User user = objectMapper.readValue(message, User.class);
36 | // return user;
37 | // }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/stream-producer/src/main/java/com/didispace/App2.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.cloud.stream.annotation.EnableBinding;
6 | import org.springframework.cloud.stream.annotation.StreamListener;
7 | import org.springframework.cloud.stream.messaging.Processor;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.integration.annotation.InboundChannelAdapter;
10 | import org.springframework.integration.annotation.Poller;
11 | import org.springframework.integration.core.MessageSource;
12 | import org.springframework.messaging.support.GenericMessage;
13 |
14 | import java.util.Date;
15 |
16 | /**
17 | *
18 | *
19 | * @author 翟永超
20 | * @create 2016/11/8.
21 | * @blog http://blog.didispace.com
22 | */
23 | //@EnableBinding(value = {Processor.class})
24 | public class App2 {
25 |
26 | private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);
27 |
28 | @Bean
29 | @InboundChannelAdapter(value = Processor.OUTPUT, poller = @Poller(fixedDelay = "2000"))
30 | public MessageSource timerMessageSource() {
31 | return () -> new GenericMessage<>(new Date());
32 | }
33 |
34 | @StreamListener(Processor.INPUT)
35 | public void receiveFromOutput(Object payload) {
36 | logger.info("Received: " + payload);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/api-gateway/src/main/java/com/didispace/filter/AccessFilter.java:
--------------------------------------------------------------------------------
1 | package com.didispace.filter;
2 |
3 | import com.netflix.zuul.ZuulFilter;
4 | import com.netflix.zuul.context.RequestContext;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | import javax.servlet.http.HttpServletRequest;
9 |
10 | public class AccessFilter extends ZuulFilter {
11 |
12 | private static Logger log = LoggerFactory.getLogger(AccessFilter.class);
13 |
14 | @Override
15 | public String filterType() {
16 | return "pre";
17 | }
18 |
19 | @Override
20 | public int filterOrder() {
21 | return 0;
22 | }
23 |
24 | @Override
25 | public boolean shouldFilter() {
26 | return true;
27 | }
28 |
29 | @Override
30 | public Object run() {
31 | RequestContext ctx = RequestContext.getCurrentContext();
32 | HttpServletRequest request = ctx.getRequest();
33 |
34 | log.info("send {} request to {}", request.getMethod(), request.getRequestURL().toString());
35 |
36 | Object accessToken = request.getParameter("accessToken");
37 | if(accessToken == null) {
38 | log.warn("access token is empty");
39 | ctx.setSendZuulResponse(false);
40 | ctx.setResponseStatusCode(401);
41 | return null;
42 | }
43 | log.info("access token ok");
44 | return null;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/api-gateway-exception/src/main/java/com/didispace/filter/error/ErrorFilter.java:
--------------------------------------------------------------------------------
1 | package com.didispace.filter.error;
2 |
3 | import com.netflix.zuul.ZuulFilter;
4 | import com.netflix.zuul.context.RequestContext;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 | import org.springframework.stereotype.Component;
8 |
9 | import javax.servlet.http.HttpServletResponse;
10 |
11 | /**
12 | * 捕获为处理的异常统一做一些处理,让`SendErrorFilter`可以正确的返回异常信息
13 | * 当是`post`过滤器抛出的话,错误信息会让`ErrorExtFilter`返回异常信息
14 | */
15 | @Component
16 | public class ErrorFilter extends ZuulFilter {
17 |
18 | Logger log = LoggerFactory.getLogger(ErrorFilter.class);
19 |
20 | @Override
21 | public String filterType() {
22 | return "error";
23 | }
24 |
25 | @Override
26 | public int filterOrder() {
27 | return 20;
28 | }
29 |
30 | @Override
31 | public boolean shouldFilter() {
32 | return true;
33 | }
34 |
35 | @Override
36 | public Object run() {
37 | RequestContext ctx = RequestContext.getCurrentContext();
38 | Throwable throwable = RequestContext.getCurrentContext().getThrowable();
39 | log.error("this is a ErrorFilter : {}", throwable.getCause().getMessage());
40 | ctx.set("error.status_code", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
41 | ctx.set("error.exception", throwable.getCause());
42 | return null;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/trace-1/src/main/java/com/didispace/TraceApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.web.bind.annotation.RequestMapping;
10 | import org.springframework.web.bind.annotation.RequestMethod;
11 | import org.springframework.web.bind.annotation.RestController;
12 | import org.springframework.web.client.RestTemplate;
13 |
14 | @RestController
15 | @EnableDiscoveryClient
16 | @SpringBootApplication
17 | public class TraceApplication {
18 |
19 | private final Logger logger = Logger.getLogger(getClass());
20 |
21 | // @Bean
22 | // public AlwaysSampler defaultSampler() {
23 | // return new AlwaysSampler();
24 | // }
25 |
26 | @Bean
27 | @LoadBalanced
28 | RestTemplate restTemplate() {
29 | return new RestTemplate();
30 | }
31 |
32 | @RequestMapping(value = "/trace-1", method = RequestMethod.GET)
33 | public String trace() {
34 | logger.info("======");
35 | return restTemplate().getForEntity("http://trace-2/trace-2", String.class).getBody();
36 | }
37 |
38 | public static void main(String[] args) {
39 | SpringApplication.run(TraceApplication.class, args);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/api-gateway-dynamic-filter/src/main/java/com/didispace/Application.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import com.netflix.zuul.FilterFileManager;
4 | import com.netflix.zuul.FilterLoader;
5 | import com.netflix.zuul.groovy.GroovyCompiler;
6 | import com.netflix.zuul.groovy.GroovyFileFilter;
7 | import org.springframework.boot.builder.SpringApplicationBuilder;
8 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
9 | import org.springframework.cloud.client.SpringCloudApplication;
10 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
11 | import org.springframework.context.annotation.Bean;
12 |
13 | @EnableZuulProxy
14 | @EnableConfigurationProperties({FilterConfiguration.class})
15 | @SpringCloudApplication
16 | public class Application {
17 |
18 | public static void main(String[] args) {
19 | new SpringApplicationBuilder(Application.class).web(true).run(args);
20 | }
21 |
22 | @Bean
23 | public FilterLoader filterLoader(FilterConfiguration filterConfiguration) {
24 | FilterLoader filterLoader = FilterLoader.getInstance();
25 | filterLoader.setCompiler(new GroovyCompiler());
26 | try {
27 | FilterFileManager.setFilenameFilter(new GroovyFileFilter());
28 | FilterFileManager.init(
29 | filterConfiguration.getInterval(),
30 | filterConfiguration.getRoot() + "/pre",
31 | filterConfiguration.getRoot() + "/post");
32 | } catch (Exception e) {
33 | throw new RuntimeException(e);
34 | }
35 | return filterLoader;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/stream-producer/src/main/java/com/didispace/SinkSender2.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.cloud.stream.annotation.EnableBinding;
6 | import org.springframework.cloud.stream.annotation.Output;
7 | import org.springframework.cloud.stream.messaging.Sink;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.integration.annotation.InboundChannelAdapter;
10 | import org.springframework.integration.annotation.Poller;
11 | import org.springframework.integration.core.MessageSource;
12 | import org.springframework.messaging.MessageChannel;
13 | import org.springframework.messaging.support.GenericMessage;
14 |
15 | /**
16 | * 快速入门
17 | *
18 | * @author 翟永超
19 | * @create 2016/11/8.
20 | * @blog http://blog.didispace.com
21 | */
22 | //@EnableBinding(value = {SinkSender2.SinkOutput.class})
23 | public class SinkSender2 {
24 |
25 | private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);
26 |
27 | @Bean
28 | @InboundChannelAdapter(value = Sink.INPUT, poller = @Poller(fixedDelay = "2000"))
29 | public MessageSource timerMessageSource() {
30 | return () -> new GenericMessage<>("{\"name\":\"didi\", \"age\":30}");
31 | }
32 |
33 | public interface SinkOutput {
34 |
35 | String OUTPUT = "input";
36 |
37 | @Output(SinkOutput.OUTPUT)
38 | MessageChannel output();
39 |
40 | }
41 | }
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/api-gateway-exception/src/main/java/com/didispace/filter/pre/ThrowExceptionFilter.java:
--------------------------------------------------------------------------------
1 | package com.didispace.filter.pre;
2 |
3 | import com.netflix.zuul.ZuulFilter;
4 | import com.netflix.zuul.context.RequestContext;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 | import org.springframework.stereotype.Component;
8 |
9 | import javax.servlet.http.HttpServletResponse;
10 |
11 | @Component
12 | public class ThrowExceptionFilter extends ZuulFilter {
13 |
14 | private static Logger log = LoggerFactory.getLogger(ThrowExceptionFilter.class);
15 |
16 | @Override
17 | public String filterType() {
18 | return "pre";
19 | }
20 |
21 | @Override
22 | public int filterOrder() {
23 | return 0;
24 | }
25 |
26 | @Override
27 | public boolean shouldFilter() {
28 | return true;
29 | }
30 |
31 | @Override
32 | public Object run() {
33 | log.info("This is a pre filter, it will throw a RuntimeException");
34 | RequestContext ctx = RequestContext.getCurrentContext();
35 | try {
36 | doSomething();
37 | } catch (Exception e) {
38 | ctx.set("error.status_code", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
39 | ctx.set("error.exception", e);
40 | // ctx.set("error.message", "有一些错误发生");
41 | }
42 | return null;
43 | }
44 |
45 | private void doSomething() {
46 | throw new RuntimeException("Exist some errors...");
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/turbine/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | turbine
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | turbine
12 |
13 |
14 | org.springframework.cloud
15 | spring-cloud-starter-parent
16 | Brixton.SR5
17 |
18 |
19 |
20 |
21 | UTF-8
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-turbine
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-actuator
34 |
35 |
36 |
37 |
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-maven-plugin
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/trace-stream-1/src/main/java/com/didispace/TraceApplication.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
8 | import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
9 | import org.springframework.context.annotation.Bean;
10 | import org.springframework.web.bind.annotation.RequestMapping;
11 | import org.springframework.web.bind.annotation.RequestMethod;
12 | import org.springframework.web.bind.annotation.RestController;
13 | import org.springframework.web.client.RestTemplate;
14 |
15 | @RestController
16 | @EnableDiscoveryClient
17 | @SpringBootApplication
18 | public class TraceApplication {
19 |
20 | private final Logger logger = Logger.getLogger(getClass());
21 |
22 | @Bean
23 | public AlwaysSampler defaultSampler() {
24 | return new AlwaysSampler();
25 | }
26 |
27 | @Bean
28 | @LoadBalanced
29 | RestTemplate restTemplate() {
30 | return new RestTemplate();
31 | }
32 |
33 | @RequestMapping(value = "/trace-1", method = RequestMethod.GET)
34 | public String trace() {
35 | logger.info("======");
36 | return restTemplate().getForEntity("http://trace-2/trace-2", String.class).getBody();
37 | }
38 |
39 | public static void main(String[] args) {
40 | SpringApplication.run(TraceApplication.class, args);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/turbine-amqp/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | turbine-amqp
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | turbine-amqp
12 |
13 |
14 | org.springframework.cloud
15 | spring-cloud-starter-parent
16 | Brixton.SR5
17 |
18 |
19 |
20 |
21 | UTF-8
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-turbine-amqp
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-actuator
34 |
35 |
36 |
37 |
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-maven-plugin
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/spring-boot-hello/src/test/java/com/didispace/HelloApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import com.didispace.web.HelloController;
4 | import org.junit.Before;
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 | import org.springframework.boot.test.SpringApplicationConfiguration;
8 | import org.springframework.http.MediaType;
9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10 | import org.springframework.test.context.web.WebAppConfiguration;
11 | import org.springframework.test.web.servlet.MockMvc;
12 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
13 | import org.springframework.test.web.servlet.setup.MockMvcBuilders;
14 |
15 | import static org.hamcrest.CoreMatchers.equalTo;
16 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
17 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
18 |
19 | @RunWith(SpringJUnit4ClassRunner.class)
20 | @SpringApplicationConfiguration(classes = HelloApplication.class)
21 | @WebAppConfiguration
22 | public class HelloApplicationTests {
23 |
24 | private MockMvc mvc;
25 |
26 | @Before
27 | public void setUp() throws Exception {
28 | mvc = MockMvcBuilders.standaloneSetup(new HelloController()).build();
29 | }
30 |
31 | @Test
32 | public void hello() throws Exception {
33 | mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
34 | .andExpect(status().isOk())
35 | .andExpect(content().string(equalTo("Hello World")));
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/stream-consumer/src/main/java/com/didispace/App1.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.cloud.stream.annotation.rxjava.EnableRxJavaProcessor;
6 | import org.springframework.cloud.stream.annotation.rxjava.RxJavaProcessor;
7 | import org.springframework.context.annotation.Bean;
8 |
9 | /**
10 | *
11 | *
12 | * @author 翟永超
13 | * @create 2016/11/8.
14 | * @blog http://blog.didispace.com
15 | */
16 | //@EnableRxJavaProcessor
17 | //@EnableBinding(value = {Processor.class})
18 | public class App1 {
19 |
20 | private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);
21 |
22 | // @StreamListener(Processor.INPUT)
23 | // @SendTo(Processor.OUTPUT)
24 | // public Object receiveFromInput(Object payload) {
25 | // logger.info("Received: " + payload);
26 | // return "From Input Channel Return - " + payload;
27 | // }
28 |
29 | /**原生实现**/
30 |
31 | // @ServiceActivator(inputChannel= Processor.INPUT, outputChannel = Processor.OUTPUT)
32 | // public Object receiveFromInput(Object payload) {
33 | // logger.info("Received: " + payload);
34 | // return "From Input Channel Return - " + payload;
35 | // }
36 |
37 | /**rxjava实现**/
38 |
39 | @Bean
40 | public RxJavaProcessor processor() {
41 | return inputStream -> inputStream.map(data -> {
42 | logger.info("Received: " + data);
43 | return data;
44 | }).buffer(5).map(data -> String.valueOf("From Input Channel Return - " + data));
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/rabbitmq-hello/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | rabbitmq-hello
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | rabbitmq-hello
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-amqp
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-maven-plugin
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/stream-producer/src/main/java/com/didispace/SinkSender4.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.cloud.stream.annotation.EnableBinding;
6 | import org.springframework.cloud.stream.annotation.Output;
7 | import org.springframework.cloud.stream.messaging.Sink;
8 | import org.springframework.cloud.stream.messaging.Source;
9 | import org.springframework.context.annotation.Bean;
10 | import org.springframework.integration.annotation.InboundChannelAdapter;
11 | import org.springframework.integration.annotation.Poller;
12 | import org.springframework.integration.core.MessageSource;
13 | import org.springframework.messaging.MessageChannel;
14 | import org.springframework.messaging.support.GenericMessage;
15 |
16 | /**
17 | * 分区消息
18 | *
19 | * @author 翟永超
20 | * @create 2016/11/8.
21 | * @blog http://blog.didispace.com
22 | */
23 | @EnableBinding(value = {Source.class})
24 | public class SinkSender4 {
25 |
26 | private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);
27 |
28 | @Bean
29 | @InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "2000"))
30 | public MessageSource timerMessageSource() {
31 | return () -> new GenericMessage<>("{\"name\":\"didi\", \"age\":30}");
32 | }
33 |
34 | // 配置属性
35 | // # Partition
36 | // spring.cloud.stream.bindings.output.destination=greetings
37 | // spring.cloud.stream.bindings.output.producer.partitionKeyExpression=payload
38 | // spring.cloud.stream.bindings.output.producer.partitionCount=2
39 | }
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/feign-consumer/src/main/java/com/didispace/web/ConsumerController.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.bind.annotation.RequestMethod;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | @RestController
9 | public class ConsumerController {
10 |
11 | @Autowired
12 | HelloService helloService;
13 | @Autowired
14 | RefactorHelloService refactorHelloService;
15 |
16 | @RequestMapping(value = "/feign-consumer", method = RequestMethod.GET)
17 | public String helloConsumer() {
18 | return helloService.hello();
19 | }
20 |
21 | @RequestMapping(value = "/feign-consumer2", method = RequestMethod.GET)
22 | public String helloConsumer2() {
23 | StringBuilder sb = new StringBuilder();
24 | sb.append(helloService.hello()).append("\n");
25 | sb.append(helloService.hello("DIDI")).append("\n");
26 | sb.append(helloService.hello("DIDI", 30)).append("\n");
27 | sb.append(helloService.hello(new User("DIDI", 30))).append("\n");
28 | return sb.toString();
29 | }
30 |
31 | @RequestMapping(value = "/feign-consumer3", method = RequestMethod.GET)
32 | public String helloConsumer3() {
33 | StringBuilder sb = new StringBuilder();
34 | sb.append(refactorHelloService.hello("MIMI")).append("\n");
35 | sb.append(refactorHelloService.hello("MIMI", 20)).append("\n");
36 | sb.append(refactorHelloService.hello(new com.didispace.dto.User("MIMI", 20))).append("\n");
37 | return sb.toString();
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/eureka-server-ha/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | eureka-server-ha
8 | 1.0.0
9 | jar
10 |
11 | eureka-server-ha
12 | Spring Cloud In Action
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-eureka-server
30 |
31 |
32 |
33 |
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-dependencies
38 | Brixton.SR5
39 | pom
40 | import
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | org.springframework.boot
49 | spring-boot-maven-plugin
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/stream-consumer/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=rabbitmq-hello
2 | server.port=8001
3 |
4 | # Topic
5 | #spring.cloud.stream.bindings.input.destination=raw-sensor-data
6 |
7 | # RabbitMQ
8 | #spring.rabbitmq.host=localhost
9 | #spring.rabbitmq.port=5672
10 | #spring.rabbitmq.username=springcloud
11 | #spring.rabbitmq.password=123456
12 |
13 | # Comsumer Group:input
14 | spring.cloud.stream.bindings.input.group=Service-A
15 |
16 | # Partition
17 | spring.cloud.stream.bindings.input.destination=greetings
18 | spring.cloud.stream.bindings.input.consumer.partitioned=true
19 | spring.cloud.stream.instanceCount=2
20 | spring.cloud.stream.instanceIndex=0
21 |
22 | # Multiple Binders
23 | #spring.cloud.stream.defaultBinder=rabbit
24 | #spring.cloud.stream.bindings.input.binder=kafka
25 |
26 | # Multiple System Setting
27 | #spring.cloud.stream.bindings.input.binder=rabbit1
28 | #spring.cloud.stream.bindings.output.binder=rabbit2
29 | #spring.cloud.stream.binders.rabbit1.type=rabbit
30 | #spring.cloud.stream.binders.rabbit1.environment.spring.rabbitmq.host=192.168.0.101
31 | #spring.cloud.stream.binders.rabbit1.environment.spring.rabbitmq.port=5672
32 | #spring.cloud.stream.binders.rabbit1.environment.spring.rabbitmq.username=springcloud
33 | #spring.cloud.stream.binders.rabbit1.environment.spring.rabbitmq.password=123456
34 | #spring.cloud.stream.binders.rabbit2.type=rabbit
35 | #spring.cloud.stream.binders.rabbit2.environment.spring.rabbitmq.host=192.168.0.102
36 | #spring.cloud.stream.binders.rabbit2.environment.spring.rabbitmq.port=5672
37 | #spring.cloud.stream.binders.rabbit2.environment.spring.rabbitmq.username=springcloud
38 | #spring.cloud.stream.binders.rabbit2.environment.spring.rabbitmq.password=123456
39 |
--------------------------------------------------------------------------------
/hystrix-dashboard/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | hystrix-dashboard
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | hystrix-dashboard
12 |
13 |
14 | org.springframework.cloud
15 | spring-cloud-starter-parent
16 | Brixton.SR5
17 |
18 |
19 |
20 |
21 | UTF-8
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-hystrix
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-hystrix-dashboard
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-actuator
38 |
39 |
40 |
41 |
42 |
43 |
44 | org.springframework.boot
45 | spring-boot-maven-plugin
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/stream-consumer/src/main/java/com/didispace/SinkReceiver3.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.cloud.stream.annotation.EnableBinding;
6 | import org.springframework.cloud.stream.annotation.StreamListener;
7 | import org.springframework.cloud.stream.messaging.Sink;
8 | import org.springframework.integration.annotation.ServiceActivator;
9 |
10 | /**
11 | * @author 翟永超
12 | * @create 2016/11/8.
13 | * @blog http://blog.didispace.com
14 | */
15 | //@EnableBinding(value = {Sink.class})
16 | public class SinkReceiver3 {
17 |
18 | private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);
19 |
20 | @StreamListener(Sink.INPUT)
21 | public void receive(User user) {
22 | logger.info("Received: " + user);
23 | }
24 |
25 | // @Bean
26 | // @InboundChannelAdapter(value = Sink.INPUT, poller = @Poller(fixedDelay = "2000"))
27 | // public MessageSource timerMessageSource() {
28 | // Map headers = new HashMap<>();
29 | // headers.put("content-type", "application/user");
30 | // return () -> new GenericMessage<>("{\"name\":\"didi\", \"age\":30}", headers);
31 | // }
32 |
33 | // Need @Transformer
34 | // @ServiceActivator(inputChannel=Sink.INPUT)
35 | // public void receive(User user) {
36 | // logger.info("Received: " + user);
37 | // }
38 |
39 | // @Transformer(inputChannel = Sink.INPUT, outputChannel = Sink.INPUT)
40 | // public User transform(String message) throws Exception {
41 | // ObjectMapper objectMapper = new ObjectMapper();
42 | // User user = objectMapper.readValue(message, User.class);
43 | // return user;
44 | // }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/diagram-uml/EurekaDiscoveryClient.uml:
--------------------------------------------------------------------------------
1 |
2 |
3 | JAVA
4 | org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient
5 |
6 | org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient
7 | com.netflix.discovery.shared.LookupService
8 | com.netflix.discovery.EurekaClient
9 | com.netflix.discovery.DiscoveryClient
10 | org.springframework.cloud.client.discovery.DiscoveryClient
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | All
35 | private
36 |
37 |
38 |
--------------------------------------------------------------------------------
/spring-boot-hello/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | spring-boot-hello
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-boot-hello
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-actuator
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-test
40 | test
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-maven-plugin
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/config-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | config-client
8 | 1.0.0
9 | jar
10 |
11 | config-client
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.boot
29 | spring-boot-starter-web
30 |
31 |
32 |
33 | org.springframework.cloud
34 | spring-cloud-starter-config
35 |
36 |
37 |
38 |
39 |
40 |
41 | org.springframework.cloud
42 | spring-cloud-dependencies
43 | Brixton.SR5
44 | pom
45 | import
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | org.springframework.boot
54 | spring-boot-maven-plugin
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/api-gateway/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | api-gateway
8 | 1.0.0
9 | jar
10 |
11 | api-gateway
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-zuul
31 |
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-eureka
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-dependencies
44 | Brixton.SR5
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-maven-plugin
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | eureka-server
8 | 1.0.0
9 | jar
10 |
11 | eureka-server
12 | Spring Cloud In Action
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-starter-eureka-server
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | org.springframework.cloud
42 | spring-cloud-dependencies
43 | Brixton.SR5
44 | pom
45 | import
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | org.springframework.boot
54 | spring-boot-maven-plugin
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/config-server-eureka/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | config-server-eureka
8 | 1.0.0
9 | jar
10 |
11 | config-server-eureka
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-server
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-eureka
34 |
35 |
36 |
37 |
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-dependencies
42 | Brixton.SR5
43 | pom
44 | import
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-maven-plugin
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/api-gateway-exception/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | api-gateway-exception
8 | 1.0.0
9 | jar
10 |
11 | api-gateway-exception
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-zuul
31 |
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-eureka
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-dependencies
44 | Brixton.SR5
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-maven-plugin
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/config-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | config-server
8 | 1.0.0
9 | jar
10 |
11 | config-server
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-server
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-dependencies
44 | Brixton.SR5
45 | pom
46 | import
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-maven-plugin
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/stream-producer/src/main/java/com/didispace/SinkSender.java:
--------------------------------------------------------------------------------
1 | package com.didispace;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.cloud.stream.annotation.EnableBinding;
6 | import org.springframework.cloud.stream.annotation.Output;
7 | import org.springframework.cloud.stream.messaging.Sink;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.integration.annotation.InboundChannelAdapter;
10 | import org.springframework.integration.annotation.Poller;
11 | import org.springframework.integration.annotation.Transformer;
12 | import org.springframework.integration.core.MessageSource;
13 | import org.springframework.messaging.MessageChannel;
14 | import org.springframework.messaging.support.GenericMessage;
15 | import org.springframework.scheduling.annotation.EnableScheduling;
16 |
17 | import java.text.SimpleDateFormat;
18 | import java.util.Date;
19 |
20 | /**
21 | * 快速入门
22 | *
23 | * @author 翟永超
24 | * @create 2016/11/8.
25 | * @blog http://blog.didispace.com
26 | */
27 | //@EnableBinding(value = {SinkSender.SinkOutput.class})
28 | public class SinkSender {
29 |
30 | private static Logger logger = LoggerFactory.getLogger(HelloApplication.class);
31 |
32 | @Bean
33 | @InboundChannelAdapter(value = SinkOutput.OUTPUT, poller = @Poller(fixedDelay = "2000"))
34 | public MessageSource timerMessageSource() {
35 | return () -> new GenericMessage<>(new Date());
36 | }
37 |
38 | @Transformer(inputChannel = Sink.INPUT, outputChannel = SinkOutput.OUTPUT)
39 | public Object transform(Date message) {
40 | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(message);
41 | }
42 |
43 | public interface SinkOutput {
44 |
45 | String OUTPUT = "input";
46 |
47 | @Output(SinkOutput.OUTPUT)
48 | MessageChannel output();
49 |
50 | }
51 | }
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/zipkin-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | zipkin-server
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | zipkin-server
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | io.zipkin.java
30 | zipkin-server
31 |
32 |
33 | io.zipkin.java
34 | zipkin-autoconfigure-ui
35 |
36 |
37 |
38 |
39 |
40 |
41 | org.springframework.cloud
42 | spring-cloud-dependencies
43 | Brixton.SR5
44 | pom
45 | import
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | org.springframework.boot
54 | spring-boot-maven-plugin
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/api-gateway-dynamic-filter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | api-gateway-dynamic-filter
8 | 1.0.0
9 | jar
10 |
11 | api-gateway-dynamic-filter
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-zuul
31 |
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-eureka
36 |
37 |
38 |
39 | org.codehaus.groovy
40 | groovy-all
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Brixton.SR5
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/config-server-eureka-kafka/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | config-server-eureka-kafka
8 | 1.0.0
9 | jar
10 |
11 | config-server-eureka-kafka
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-server
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-eureka
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-bus-kafka
38 |
39 |
40 |
41 |
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-dependencies
46 | Brixton.SR5
47 | pom
48 | import
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | org.springframework.boot
57 | spring-boot-maven-plugin
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/config-server-eureka-rabbit/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | config-server-eureka-rabbit
8 | 1.0.0
9 | jar
10 |
11 | config-server-eureka-rabbit
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.cloud
29 | spring-cloud-config-server
30 |
31 |
32 | org.springframework.cloud
33 | spring-cloud-starter-eureka
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-bus-amqp
38 |
39 |
40 |
41 |
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-dependencies
46 | Brixton.SR5
47 | pom
48 | import
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | org.springframework.boot
57 | spring-boot-maven-plugin
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/api-gateway-dynamic-route/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | api-gateway-dynamic-route
8 | 1.0.0
9 | jar
10 |
11 | api-gateway-dynamic-route
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-starter-zuul
31 |
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-eureka
36 |
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-starter-config
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-dependencies
50 | Brixton.SR5
51 | pom
52 | import
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | org.springframework.boot
61 | spring-boot-maven-plugin
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/zipkin-server-stream/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | zipkin-server-stream
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | zipkin-server-stream
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-sleuth-zipkin-stream
31 |
32 |
33 | org.springframework.cloud
34 | spring-cloud-starter-stream-rabbit
35 |
36 |
37 | io.zipkin.java
38 | zipkin-autoconfigure-ui
39 |
40 |
41 |
42 |
43 |
44 |
45 | org.springframework.cloud
46 | spring-cloud-dependencies
47 | Brixton.SR5
48 | pom
49 | import
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | org.springframework.boot
58 | spring-boot-maven-plugin
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/hello-service/src/main/java/com/didispace/web/HelloController.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.cloud.client.ServiceInstance;
6 | import org.springframework.cloud.client.discovery.DiscoveryClient;
7 | import org.springframework.web.bind.annotation.*;
8 |
9 | import java.util.Random;
10 |
11 | @RestController
12 | public class HelloController {
13 |
14 | private final Logger logger = Logger.getLogger(getClass());
15 |
16 | @Autowired
17 | private DiscoveryClient client;
18 |
19 | @RequestMapping(value = "/hello", method = RequestMethod.GET)
20 | public String hello() throws Exception {
21 | ServiceInstance instance = client.getLocalServiceInstance();
22 |
23 | // 测试超时触发断路器
24 | // int sleepTime = new Random().nextInt(3000);
25 | // logger.info("sleepTime:" + sleepTime);
26 | // Thread.sleep(sleepTime);
27 |
28 | logger.info("/hello, host:" + instance.getHost() + ", service_id:" + instance.getServiceId());
29 | return "Hello World";
30 | }
31 |
32 | @RequestMapping(value = "/hello1", method = RequestMethod.GET)
33 | public String hello(@RequestParam String name) {
34 | ServiceInstance instance = client.getLocalServiceInstance();
35 | logger.info("/hello1, host:" + instance.getHost() + ", service_id:" + instance.getServiceId());
36 | return "Hello " + name;
37 | }
38 |
39 | @RequestMapping(value = "/hello2", method = RequestMethod.GET)
40 | public User hello(@RequestHeader String name, @RequestHeader Integer age) {
41 | ServiceInstance instance = client.getLocalServiceInstance();
42 | logger.info("/hello2, host:" + instance.getHost() + ", service_id:" + instance.getServiceId());
43 | return new User(name, age);
44 | }
45 |
46 | @RequestMapping(value = "/hello3", method = RequestMethod.POST)
47 | public String hello(@RequestBody User user) {
48 | ServiceInstance instance = client.getLocalServiceInstance();
49 | logger.info("/hello3, host:" + instance.getHost() + ", service_id:" + instance.getServiceId());
50 | return "Hello "+ user.getName() + ", " + user.getAge();
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/stream-producer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | stream-producer
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | stream-producer
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-starter-stream-rabbit
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | Brixton.SR5
50 | pom
51 | import
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.boot
60 | spring-boot-maven-plugin
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | spring-cloud-in-action
8 | pom
9 | 1.0
10 |
11 |
12 | spring-boot-hello
13 | eureka-server
14 | eureka-server-ha
15 | hello-service
16 |
17 | ribbon-consumer
18 | feign-consumer
19 |
20 | hello-service-api
21 |
22 | api-gateway
23 | api-gateway-exception
24 | api-gateway-dynamic-route
25 | api-gateway-dynamic-filter
26 |
27 | config-server
28 | config-client
29 |
30 | config-server-eureka
31 | config-client-eureka
32 |
33 | config-server-eureka-rabbit
34 | config-client-eureka-rabbit
35 |
36 | config-server-eureka-kafka
37 | config-client-eureka-kafka
38 |
39 | rabbitmq-hello
40 |
41 | hystrix-dashboard
42 | turbine
43 | turbine-amqp
44 |
45 | stream-consumer
46 | stream-producer
47 |
48 | trace-1
49 | trace-2
50 | zipkin-server
51 |
52 | trace-stream-1
53 | trace-stream-2
54 | zipkin-server-stream
55 | zipkin-server-stream-mysql
56 |
57 | consul-client-1
58 | api-gateway-consul
59 |
60 |
61 |
--------------------------------------------------------------------------------
/config-client-eureka/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | config-client-eureka
8 | 1.0.0
9 | jar
10 |
11 | config-client-eureka
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.retry
29 | spring-retry
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-web
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-aop
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-config
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-eureka
46 |
47 |
48 |
49 |
50 |
51 |
52 | org.springframework.cloud
53 | spring-cloud-dependencies
54 | Brixton.SR5
55 | pom
56 | import
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.boot
65 | spring-boot-maven-plugin
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/zipkin-server-stream-mysql/src/main/resources/mysql.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE IF NOT EXISTS zipkin_spans (
2 | `trace_id` BIGINT NOT NULL,
3 | `id` BIGINT NOT NULL,
4 | `name` VARCHAR(255) NOT NULL,
5 | `parent_id` BIGINT,
6 | `debug` BIT(1),
7 | `start_ts` BIGINT COMMENT 'Span.timestamp(): epoch micros used for endTs query and to implement TTL',
8 | `duration` BIGINT COMMENT 'Span.duration(): micros used for minDuration and maxDuration query'
9 | ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
10 |
11 | ALTER TABLE zipkin_spans ADD UNIQUE KEY(`trace_id`, `id`) COMMENT 'ignore insert on duplicate';
12 | ALTER TABLE zipkin_spans ADD INDEX(`trace_id`, `id`) COMMENT 'for joining with zipkin_annotations';
13 | ALTER TABLE zipkin_spans ADD INDEX(`trace_id`) COMMENT 'for getTracesByIds';
14 | ALTER TABLE zipkin_spans ADD INDEX(`name`) COMMENT 'for getTraces and getSpanNames';
15 | ALTER TABLE zipkin_spans ADD INDEX(`start_ts`) COMMENT 'for getTraces ordering and range';
16 |
17 | CREATE TABLE IF NOT EXISTS zipkin_annotations (
18 | `trace_id` BIGINT NOT NULL COMMENT 'coincides with zipkin_spans.trace_id',
19 | `span_id` BIGINT NOT NULL COMMENT 'coincides with zipkin_spans.id',
20 | `a_key` VARCHAR(255) NOT NULL COMMENT 'BinaryAnnotation.key or Annotation.value if type == -1',
21 | `a_value` BLOB COMMENT 'BinaryAnnotation.value(), which must be smaller than 64KB',
22 | `a_type` INT NOT NULL COMMENT 'BinaryAnnotation.type() or -1 if Annotation',
23 | `a_timestamp` BIGINT COMMENT 'Used to implement TTL; Annotation.timestamp or zipkin_spans.timestamp',
24 | `endpoint_ipv4` INT COMMENT 'Null when Binary/Annotation.endpoint is null',
25 | `endpoint_port` SMALLINT COMMENT 'Null when Binary/Annotation.endpoint is null',
26 | `endpoint_service_name` VARCHAR(255) COMMENT 'Null when Binary/Annotation.endpoint is null'
27 | ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
28 |
29 | ALTER TABLE zipkin_annotations ADD UNIQUE KEY(`trace_id`, `span_id`, `a_key`, `a_timestamp`) COMMENT 'Ignore insert on duplicate';
30 | ALTER TABLE zipkin_annotations ADD INDEX(`trace_id`, `span_id`) COMMENT 'for joining with zipkin_spans';
31 | ALTER TABLE zipkin_annotations ADD INDEX(`trace_id`) COMMENT 'for getTraces/ByIds';
32 | ALTER TABLE zipkin_annotations ADD INDEX(`endpoint_service_name`) COMMENT 'for getTraces and getServiceNames';
33 | ALTER TABLE zipkin_annotations ADD INDEX(`a_type`) COMMENT 'for getTraces';
34 | ALTER TABLE zipkin_annotations ADD INDEX(`a_key`) COMMENT 'for getTraces';
35 | ALTER TABLE zipkin_annotations ADD INDEX(`endpoint_ipv4`) COMMENT 'for getTraces ordering';
36 |
--------------------------------------------------------------------------------
/stream-consumer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | stream-consumer
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | stream-consumer
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-starter-stream-rabbit
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | org.springframework.cloud
50 | spring-cloud-stream-rxjava
51 | 1.0.2.RELEASE
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.springframework.cloud
60 | spring-cloud-dependencies
61 | Brixton.SR6
62 | pom
63 | import
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | org.springframework.boot
72 | spring-boot-maven-plugin
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/zipkin-server-stream-mysql/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | zipkin-server-stream-mysql
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | zipkin-server-stream-mysql
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.cloud
30 | spring-cloud-sleuth-zipkin-stream
31 |
32 |
33 | org.springframework.cloud
34 | spring-cloud-starter-stream-rabbit
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-starter-jdbc
39 |
40 |
41 | mysql
42 | mysql-connector-java
43 |
44 |
45 | io.zipkin.java
46 | zipkin-autoconfigure-ui
47 |
48 |
49 | org.jooq
50 | jooq
51 | 3.8.0
52 |
53 |
54 |
55 |
56 |
57 |
58 | org.springframework.cloud
59 | spring-cloud-dependencies
60 | Brixton.SR5
61 | pom
62 | import
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | org.springframework.boot
71 | spring-boot-maven-plugin
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/trace-1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | trace-1
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | trace-1
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-eureka
36 |
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-starter-sleuth
41 |
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-ribbon
46 |
47 |
48 |
49 | org.springframework.cloud
50 | spring-cloud-sleuth-zipkin
51 |
52 |
53 |
54 | net.logstash.logback
55 | logstash-logback-encoder
56 | 4.6
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.cloud
65 | spring-cloud-dependencies
66 | Brixton.SR5
67 | pom
68 | import
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | org.springframework.boot
77 | spring-boot-maven-plugin
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/trace-2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | trace-2
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | trace-2
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-eureka
36 |
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-starter-ribbon
41 |
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-sleuth
46 |
47 |
48 |
49 | net.logstash.logback
50 | logstash-logback-encoder
51 | 4.6
52 |
53 |
54 |
55 | org.springframework.cloud
56 | spring-cloud-sleuth-zipkin
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.cloud
65 | spring-cloud-dependencies
66 | Brixton.SR5
67 | pom
68 | import
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | org.springframework.boot
77 | spring-boot-maven-plugin
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/trace-stream-1/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | trace-stream-1
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | trace-stream-1
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-eureka
36 |
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-starter-sleuth
41 |
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-ribbon
46 |
47 |
48 |
49 | org.springframework.cloud
50 | spring-cloud-sleuth-stream
51 |
52 |
53 |
54 | org.springframework.cloud
55 | spring-cloud-starter-stream-rabbit
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.cloud
64 | spring-cloud-dependencies
65 | Brixton.SR5
66 | pom
67 | import
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | org.springframework.boot
76 | spring-boot-maven-plugin
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/trace-stream-2/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | trace-stream-2
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | trace-stream-2
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-eureka
36 |
37 |
38 |
39 | org.springframework.cloud
40 | spring-cloud-starter-ribbon
41 |
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-sleuth
46 |
47 |
48 |
49 | org.springframework.cloud
50 | spring-cloud-sleuth-stream
51 |
52 |
53 |
54 | org.springframework.cloud
55 | spring-cloud-starter-stream-rabbit
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.cloud
64 | spring-cloud-dependencies
65 | Brixton.SR5
66 | pom
67 | import
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | org.springframework.boot
76 | spring-boot-maven-plugin
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/config-client-eureka-kafka/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | config-client-eureka-kafka
8 | 1.0.0
9 | jar
10 |
11 | config-client-eureka-kafka
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.retry
29 | spring-retry
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-web
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-aop
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-actuator
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-config
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-starter-eureka
50 |
51 |
52 | org.springframework.cloud
53 | spring-cloud-starter-bus-kafka
54 |
55 |
56 |
57 |
58 |
59 |
60 | org.springframework.cloud
61 | spring-cloud-dependencies
62 | Brixton.SR5
63 | pom
64 | import
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | org.springframework.boot
73 | spring-boot-maven-plugin
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/config-client-eureka-rabbit/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | config-client-eureka-rabbit
8 | 1.0.0
9 | jar
10 |
11 | config-client-eureka-rabbit
12 | Spring Cloud project
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | 1.8
24 |
25 |
26 |
27 |
28 | org.springframework.retry
29 | spring-retry
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-web
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-aop
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-actuator
42 |
43 |
44 | org.springframework.cloud
45 | spring-cloud-starter-config
46 |
47 |
48 | org.springframework.cloud
49 | spring-cloud-starter-eureka
50 |
51 |
52 | org.springframework.cloud
53 | spring-cloud-starter-bus-amqp
54 |
55 |
56 |
57 |
58 |
59 |
60 | org.springframework.cloud
61 | spring-cloud-dependencies
62 | Brixton.SR5
63 | pom
64 | import
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | org.springframework.boot
73 | spring-boot-maven-plugin
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/feign-consumer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | feign-consumer
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | feign-consumer
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-actuator
42 |
43 |
44 |
45 | org.springframework.cloud
46 | spring-cloud-starter-eureka
47 |
48 |
49 |
50 | org.springframework.cloud
51 | spring-cloud-starter-feign
52 |
53 |
54 |
55 | com.didispace
56 | hello-service-api
57 | 0.0.1-SNAPSHOT
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.cloud
65 | spring-cloud-dependencies
66 | Brixton.SR5
67 | pom
68 | import
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | org.springframework.boot
77 | spring-boot-maven-plugin
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/hello-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | hello-service
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | hello-service
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-eureka
42 |
43 |
44 |
45 | org.springframework.cloud
46 | spring-cloud-starter-hystrix
47 |
48 |
49 |
50 | org.springframework.boot
51 | spring-boot-starter-actuator
52 |
53 |
54 |
55 | com.didispace
56 | hello-service-api
57 | 0.0.1-SNAPSHOT
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.cloud
65 | spring-cloud-dependencies
66 | Brixton.SR5
67 | pom
68 | import
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | org.springframework.boot
77 | spring-boot-maven-plugin
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/ribbon-consumer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.didispace
7 | ribbon-consumer
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | ribbon-consumer
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.7.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter-test
36 | test
37 |
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-starter-eureka
42 |
43 |
44 |
45 | org.springframework.cloud
46 | spring-cloud-starter-ribbon
47 |
48 |
49 |
50 | org.springframework.boot
51 | spring-boot-starter-actuator
52 |
53 |
54 |
55 | org.springframework.cloud
56 | spring-cloud-starter-hystrix
57 |
58 |
59 |
60 | org.springframework.cloud
61 | spring-cloud-netflix-hystrix-amqp
62 |
63 |
64 |
65 |
66 |
67 |
68 | org.springframework.cloud
69 | spring-cloud-dependencies
70 | Brixton.SR5
71 | pom
72 | import
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | org.springframework.boot
81 | spring-boot-maven-plugin
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/ribbon-consumer/src/main/java/com/didispace/web/HelloService.java:
--------------------------------------------------------------------------------
1 | package com.didispace.web;
2 |
3 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
4 | import org.apache.log4j.Logger;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.stereotype.Service;
8 | import org.springframework.web.client.RestTemplate;
9 | import org.springframework.web.util.UriComponents;
10 | import org.springframework.web.util.UriComponentsBuilder;
11 |
12 | import java.net.URI;
13 | import java.util.HashMap;
14 | import java.util.Map;
15 |
16 | @Service
17 | public class HelloService {
18 |
19 | private final Logger logger = Logger.getLogger(getClass());
20 |
21 | @Autowired
22 | RestTemplate restTemplate;
23 |
24 | @HystrixCommand(fallbackMethod = "helloFallback", commandKey = "helloKey")
25 | public String hello() {
26 | long start = System.currentTimeMillis();
27 |
28 | StringBuilder result = new StringBuilder();
29 |
30 | // GET
31 | result.append(restTemplate.getForEntity("http://HELLO-SERVICE/hello", String.class).getBody()).append("
");
32 | result.append(restTemplate.getForEntity("http://HELLO-SERVICE/hello1?name={1}", String.class, "didi").getBody()).append("
");
33 |
34 | Map params = new HashMap<>();
35 | params.put("name", "dada");
36 | result.append(restTemplate.getForEntity("http://HELLO-SERVICE/hello1?name={name}", String.class, params).getBody()).append("
");
37 |
38 | UriComponents uriComponents = UriComponentsBuilder.fromUriString(
39 | "http://HELLO-SERVICE/hello1?name={name}")
40 | .build()
41 | .expand("dodo")
42 | .encode();
43 | URI uri = uriComponents.toUri();
44 | result.append(restTemplate.getForEntity(uri, String.class).getBody()).append("
");
45 |
46 | // POST
47 | User user = new User("didi", 20);
48 | String postResult = restTemplate.postForObject("http://HELLO-SERVICE/hello3", user, String.class);
49 | result.append(postResult).append("
");
50 |
51 | user = new User("didi", 30);
52 | ResponseEntity responseEntity = restTemplate.postForEntity("http://HELLO-SERVICE/hello3", user, String.class);
53 | result.append(responseEntity.getBody()).append("
");
54 |
55 | // user = new User("didi", 40);
56 | // URI responseURI = restTemplate.postForLocation("http://HELLO-SERVICE/hello3", user);
57 | // result.append(responseURI).append("
");
58 | //
59 | // Long id = 10001L;
60 | // restTemplate.delete("http://USER-SERVICE/user/{1}", id);
61 |
62 | long end = System.currentTimeMillis();
63 |
64 | logger.info("Spend time : " + (end - start) );
65 | return result.toString();
66 | }
67 |
68 | public String helloFallback() {
69 | return "error";
70 | }
71 |
72 | }
--------------------------------------------------------------------------------
/trace-2/src/main/resources/logback-spring.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
11 |
12 |
13 |
14 |
15 |
16 | INFO
17 |
18 |
19 | ${CONSOLE_LOG_PATTERN}
20 | utf8
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | ${LOG_FILE}.json
40 |
41 | ${LOG_FILE}.json.%d{yyyy-MM-dd}.gz
42 | 7
43 |
44 |
45 |
46 |
47 | UTC
48 |
49 |
50 |
51 | {
52 | "severity": "%level",
53 | "service": "${springAppName:-}",
54 | "trace": "%X{X-B3-TraceId:-}",
55 | "span": "%X{X-B3-SpanId:-}",
56 | "exportable": "%X{X-Span-Export:-}",
57 | "pid": "${PID:-}",
58 | "thread": "%thread",
59 | "class": "%logger{40}",
60 | "rest": "%message"
61 | }
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/diagram-uml/BusEvent.uml:
--------------------------------------------------------------------------------
1 |
2 |
3 | JAVA
4 | org.springframework.cloud.bus.event.AckRemoteApplicationEvent
5 |
6 | org.springframework.cloud.bus.event.EnvironmentChangeRemoteApplicationEvent
7 | org.springframework.cloud.bus.event.EnvironmentChangeListener
8 | org.springframework.cloud.bus.event.RemoteApplicationEvent
9 | org.springframework.context.ApplicationListener
10 | java.util.EventObject
11 | org.springframework.cloud.bus.event.TraceListener
12 | org.springframework.context.ApplicationEvent
13 | java.util.EventListener
14 | org.springframework.cloud.bus.event.RefreshListener
15 | org.springframework.cloud.bus.event.AckRemoteApplicationEvent
16 | org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent
17 | org.springframework.cloud.bus.event.SentApplicationEvent
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | All
82 | private
83 |
84 |
85 |
--------------------------------------------------------------------------------
/diagram-uml/BusListener.uml:
--------------------------------------------------------------------------------
1 |
2 |
3 | JAVA
4 | org.springframework.cloud.bus.event.AckRemoteApplicationEvent
5 |
6 | org.springframework.cloud.bus.event.EnvironmentChangeRemoteApplicationEvent
7 | org.springframework.cloud.bus.event.EnvironmentChangeListener
8 | org.springframework.cloud.bus.event.RemoteApplicationEvent
9 | org.springframework.context.ApplicationListener
10 | java.util.EventObject
11 | org.springframework.cloud.bus.event.TraceListener
12 | org.springframework.context.ApplicationEvent
13 | java.util.EventListener
14 | org.springframework.cloud.bus.event.RefreshListener
15 | org.springframework.cloud.bus.event.AckRemoteApplicationEvent
16 | org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent
17 | org.springframework.cloud.bus.event.SentApplicationEvent
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | All
82 | private
83 |
84 |
85 |
--------------------------------------------------------------------------------
/diagram-uml/BusEventAndListener.uml:
--------------------------------------------------------------------------------
1 |
2 |
3 | JAVA
4 | org.springframework.cloud.bus.event.AckRemoteApplicationEvent
5 |
6 | org.springframework.cloud.bus.event.EnvironmentChangeRemoteApplicationEvent
7 | org.springframework.cloud.bus.event.EnvironmentChangeListener
8 | org.springframework.cloud.bus.event.RemoteApplicationEvent
9 | org.springframework.context.ApplicationListener
10 | java.util.EventObject
11 | org.springframework.cloud.bus.event.TraceListener
12 | org.springframework.context.ApplicationEvent
13 | java.util.EventListener
14 | org.springframework.cloud.bus.event.RefreshListener
15 | org.springframework.cloud.bus.event.AckRemoteApplicationEvent
16 | org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent
17 | org.springframework.cloud.bus.event.SentApplicationEvent
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | All
82 | private
83 |
84 |
85 |
--------------------------------------------------------------------------------