使用RabbitMQ来进行微服务的监管

返回目录

https://blog.csdn.net/BW_Bear/article/details/88746646

源码位置

微服务注册管理:

https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Hystrix实现容错/microservice-discovery-eureka

生产者:

https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Hystrix实现容错/microservice-provider-user

消费者:

https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Hystrix实现容错/使用消息中间件收集数据/microservice-consumer-movie-ribbon-hystrix-turbine-mq

Turbine:

https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Hystrix实现容错/使用消息中间件收集数据/hystrix-turbine-mq

1.改造消费者微服务

1.1 添加依赖

		<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>sprint-cloud-netflix-hystrix-stream</artifactId>
        </dependency>

        <!--rabbit 依赖-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>sprint-cloud-starter-stream-rabbit</artifactId>
        </dependency>

1.2 修改配置文件

添加

spring:
  rabbitmq:
    host: localhost
    port: 5672
    username: guest
    password: guest

2.改造Turbine

1.1 添加依赖

		<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>sprint-cloud-netflix-hystrix-stream</artifactId>
        </dependency>

        <!--rabbit 依赖-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>sprint-cloud-starter-stream-rabbit</artifactId>
        </dependency>

1.2 修改配置文件

添加

spring:
  rabbitmq:
    host: localhost
    port: 5672
    username: guest
    password: guest

同时删除:

turbine:
  app-config: MICROSERVICE-CONSUMER-MOVIE-1,MICROSERVICE-CONSUMER-MOVIE-2
  cluster-name-expression: "'default'"

这样就都OK了,可以测试了

测试

1.启动eureka、生产者、消费者

2.启动Turbine

3.访问消费者服务

在这里插入图片描述

4.访问Turbine

在这里插入图片描述

返回目录

https://blog.csdn.net/BW_Bear/article/details/88746646

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值