Turbine ist ein Werkzeug, mit dem Server zum Senden von Ereignisstromdaten gesendet werden können. Bei der Hystrix -Überwachung kann nur ein einzelner Knoten überwacht werden, und in der tatsächlichen Produktion sind sie Cluster. Daher kann Turbine verwendet werden, um die Metriken von Hytrix im Cluster zu überwachen, und Hytrixdienste können über Eureka entdeckt werden.
Erstellen Sie ein neues Turbinenprojekt
TurbineApplication.java
Paketturbine; import org.springframework.boot.springApplication; import org.springframework.boot.autoconFigure.springbootApplication; import org.springframework.cloud.netflix.hystrix.enablehystrix; org.springframework.cloud.netflix.hystrix.dashboard.enableHyStrixdashboard; import org.springframework.cloud.netflix.turbine.enableturbine;/*** Erstellt von Sai.luo am 2017/4/26. */@SpringBootApplication@enableTurbine@enableHyStrix@enableHyStrixDashboardPublic Class TurbineApplication {public static void main (String [] args) {Springapplication.run (TurbineApplication.Class, Argumentation); }}pom.xml
<? xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>turbine</artifactId> <properties> <project.build.sourceEnecoding> utf-8 </project.build.SourceCoding> <java.version> 1.8 </java.version> </properties> <eledium> <gruppe org. <version> 1.5.2.Release </Version> <relativePath/> <!-SOOKUP-Übergeordnete aus Repository-> </übergeordnet> <Abhängigkeiten> <!-Hystrix-Abhängigkeiten-> <Depopentcy> <Groupid> org.springFramework <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> </dependency> <!-- turnbine dependencies--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-turbine</artifactId> </dependency> </dependency> </dependency> <dependencyManagement> <dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Camden.SR5</version> <type>pom</type> <scope>import</scope> </dependency> </dependency> </dependency> </dependency> </abhängigManagement> <builds> <plugins> <PLUGIN> <gruppe> org.springFramework
application.yml
Frühling: Anwendung: Name: Tründinesserver: Port: 8000 Turbine: App-Config: Hallo, Helloclient ## Service-Name, der überwacht werden muss, Aggregator: ClusterConfig: Hauptname ## Service Cluster-Name, der über überwacht werden muss, um CluSernameExpression: metadata ['cluster'] Eureka: Instanz: echte Status: /statesipaddress: echte Statusurlpath: /info. serviceurl: defaultZone: http: // localhost: 8761/eureka/
Starten Sie den Service
HelloServiceEureka Project Application.yml fügt Cluster -Konfiguration hinzu
Wechseln zu
spring: application: name: helloserver: port: 9001eureka: instance: lease-renewal-interval-in-seconds: 3 lease-expiration-duration-in-seconds: 5 metadata-map: cluster: main client: serviceUrl: defaultZone: http://localhost:8761/eureka/ registry-fetch-interval-seconds: 3logging: Level: com: netflix: eureka: off Discovery: off
pom.xml fügt das Hystrix -Abhängigkeitspaket hinzu
<Depopenty> <gruppe> org.springFramework.cloud </Groupid> <artifactId> Spring-Cloud-Starter-Hystrix </artifactid> </abhängig>
In ähnlicher Weise fügt Ribboneureka Project Application.yml Clusterkonfiguration hinzu
Nach der Änderung die folgenden
Frühling: Anwendung: Name: HelloClientServer: Port: 20000eureka: Instanz: Leasing-Renewal-Interval-in-Sekunden: 3 Lease-Expiration-in-Sekunden Level: com: netflix: eureka: off Discovery: off
pom.xml fügt das Hystrix -Abhängigkeitspaket hinzu
Ribboneurekaapplication.java Annotation hinzufügen
@EnableHystrix
Starten Sie das Projekt
Besuchen Sie localhost: 8000/hystrixx, um die Seite zu sehen
HINWEIS: Turbine kann nur den Hystrix -Dienst überwachen, nicht den Hystrix -Dienst und kann ihn nicht überwachen. Obwohl der Hallo -Dienst mit einem Cluster konfiguriert ist, wird beispielsweise Hystrix nicht verwendet, sodass er nicht überwacht wird.
Projektadresse https://github.com/luosai001/spring-cloud-stample/tree/master
Das obige ist der gesamte Inhalt dieses Artikels. Ich hoffe, es wird für das Lernen aller hilfreich sein und ich hoffe, jeder wird Wulin.com mehr unterstützen.