4.0.0
com.dan
service-turbine
0.0.1-SNAPSHOT
jar
service-turbine
Demo project for Spring Boot
org.springframework.boot
spring-boot-starter-parent
1.5.9.RELEASE
UTF-8
UTF-8
1.8
Edgware.SR1
org.springframework.cloud
spring-cloud-starter-turbine
org.springframework.cloud
spring-cloud-netflix-turbine
org.springframework.boot
spring-boot-starter-actuator
org.springframework.boot
spring-boot-starter-test
test
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin
@SpringBootApplication
@EnableTurbine
public class ServiceTurbineApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceTurbineApplication.class, args);
}
}
在application.properties中加入Eureka和Turbine的相关配置,具体如下:
spring.application.name=service-turbine
server.port=8766
security.basic.enabled=false
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
turbine.aggregator.cluster-config=default
turbine.app-config=service-ribbon
turbine.cluster-name-expression="default"
turbine.combine-host-port=true
http://localhost:8766/turbine.stream
4.0.0
com.dan
service-turbine-amqp
0.0.1-SNAPSHOT
jar
service-turbine-amqp
Demo project for Spring Boot
org.springframework.boot
spring-boot-starter-parent
1.5.9.RELEASE
UTF-8
UTF-8
1.8
Edgware.SR1
org.springframework.cloud
spring-cloud-starter-turbine-amqp
org.springframework.boot
spring-boot-starter-actuator
test
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin
在主类中使用@EnableTurbineStream注解来启用Turbine Stream的配置:
@SpringBootApplication
@EnableTurbineStream
@EnableDiscoveryClient
public class ServiceTurbineAmqpApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceTurbineAmqpApplication.class, args);
}
}
接着配置application.properties文件:
spring.application.name=service-turbine-amqp
server.port=8766
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
对于Turbine的配置已经完成了,下面需要对service-ribbon做一些修改,使其监控信息能够输出到RabbitMQ上。这个修改也非常简单,只需在pom.xml中增加对spring-cloud-netflix-hystrix-amqp的依赖,具体如下:
org.springframework.cloud
spring-cloud-netflix-hystrix-amqp
http://localhost:8765/hystrix http://localhost:8766/turbine.stream
https://github.com/lingd3/SpringCloudLearning/tree/master/chapter8