微服务springcloud—使用消息中间件收集数据

前文是用HTTP直接收集跟踪数据的,本节来讨论如何使用消息中间件收集追踪数据。相比HTTP的方式来说,使用消息中间件有以下优点:

  • 微服务与Zipkin Server解耦,微服务无需知道Zipkin Server的网络地址。
  • 一些场景下,ZipkinServer与微服务网络可能不通,使用HTTP直接收集的方式无法工作,此时可借助消息中间件来实现数据收集。

改造Zipkin Server

1.复制项目microservice-trace-zipkin-server,将ArtifactId修改为microservice-trace-zipkin-server-stream。
2.将pom.xml的依赖修改为以下内容。

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
        </dependency>
		 <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-ui</artifactId>
        </dependency>

3.修改启动类,将注解@EnableZipkinServer修改为@EnableZipkinStreamServer。
4.修改配置文件application.yml


本文大部分内容转载自周立的《Spring Cloud与Docker微服务架构实战》

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值