Spring Cloud 之Spring Cloud Bus(二)
来源:互联网 发布:阿伦特海德格尔 知乎 编辑:程序博客网 时间:2024/04/28 15:59
一、介绍
Spring Cloud Bus 使用消息中间件连接分布式系统的各个节点,然后可以使用它来广播状态更改(例如配置更改)或其他管理指令。一个关键的想法是,总线就像一个分布式执行器,用于启动一个扩展的Spring引导应用程序,但它也可以用作应用程序之间的通信通道。目前只实现了一个AMQP协议的中间件作为传输。Spring Cloud Bus目前只实现了Rabbitmq 和kafka作为消息中间件。
二、环境准备
下面以Rabbitmq 作为消息中间件讲解Spring Cloud Bus
需要下载安装erlang,rabbitmq, 启动rabbitmq服务。
三、在Config Client中增加一个依赖包spring-cloud-start-bu-amqp
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bus-amqp</artifactId></dependency>在bootstrap.yml 增加配置rabbitmq相关配置
spring: application: name: spring-cloud-config-client profiles: active: dev cloud: config: uri: http://localhost:8888 profile: dev rabbitmq: host: localhost port: 5672 username: guest password: guestmanagement: security: enabled: falseserver: port: 9000
host 主机名
port:端口号
username:用户名
password:密码
启动两个实例,使用两个端口号:9000 和9001 ,修改foo配置信息 ,我们只更新9000这个应用的配置,如果9001也更新了,说明Spring Cloud Bus 起作用了。在命令行执行 curl -X POST http://localhost:9000/bus/refresh 后
分别访问 http://localhost:9000/hi ,http://localhost:9001/hi 会发现返回来的信息都是最新的 。说明更新成功了。
参考文档 http://projects.spring.io/spring-cloud/spring-cloud.html#_spring_cloud_bus
阅读全文
0 0
- Spring Cloud 之Spring Cloud Bus(二)
- Spring Cloud Bus 教程
- Spring Cloud Bus
- Spring Cloud Bus
- Spring Cloud Bus
- Spring Cloud Bus之RabbitMQ初窥
- Spring cloud-Bus (消息总线)
- Spring Cloud Bus整合RabbitMQ
- Spring Cloud Bus整合Kafka
- Spring Cloud Bus 配置更新
- Spring Cloud实战(六)-Spring Cloud Netflix Bus
- Spring-Cloud系列第6篇:spring-cloud-bus
- Spring Cloud实战(六)-Spring Cloud Netflix Bus
- spring cloud bus 和 spring cloud stream 的使用场景
- Spring Cloud (3) | spring cloud bus 消息总线kafka应用
- Spring Cloud实战(二)-Spring Cloud Eureka
- Spring Cloud实战(二)-Spring Cloud Eureka
- Spring5学习(二)-spring projects之Spring Cloud
- IP的获取与转换
- C#中使用正则的贪婪和非贪婪模式,以及分组
- Web项目的三层架构和MVC架构异同
- CAD转为jpg的方法
- Python基础教程视频集锦
- Spring Cloud 之Spring Cloud Bus(二)
- SQL语句,更新字段,旧值是新值的一部分
- JQuery DataTables的学习笔记整理
- Python格式化输出%s和%d
- Unity 代码实现表针转动
- C#多线程实现方法——异步委托/调用(二)
- B
- hdu 6140 bitset+背包
- fiddler在ios10.3系统抓包https失败原因解决