springcloud21---Config-bus实现配置自动刷新
Pivotal(毕威拓)有VMware和EMC成立的.
RabbitMQ是由ERlang(爱立信开发的,面向并发的编程语言),安装RabbitMQ先要安装ERlang。
- package com.itmuch.cloud;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.cloud.context.config.annotation.RefreshScope;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RestController;
- @RestController
- //配置自动刷新,config server不用改,config client要改。
- @RefreshScope //加入配置自动刷新注解,当配置发生更改的时候这个bean会
- //各个微服务启动了,config client已经加载配置了,即使config server挂了也可以。
- public class ConfigClientController {
- @Value("${profile}")
- private String profile;
- @GetMapping("/profile")
- public String getProfile() {
- return this.profile;
- }
- }
- package com.itmuch.cloud;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- @SpringBootApplication
- public class ConfigServerApplication {
- public static void main(String[] args) {
- SpringApplication.run(ConfigServerApplication.class, args);
- }
- }
application.yml
- server:
- port:
bootstrap.yml
- spring:
- cloud:
- config: #config server的地址
- uri: http://localhost:8080
- profile: dev
- label: master # 当configserver的后端存储是Git时,默认就是master
- bus:
- trace:
- enabled: true
- application:
- name: foobar
- #连接rabbitmq
- rabbitmq:
- host: localhost
- port:
- username: guest
- password: guest
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.</modelVersion>
- <parent>
- <groupId>com.itmuch.cloud</groupId>
- <artifactId>microservice-spring-cloud</artifactId>
- <version>0.0.-SNAPSHOT</version>
- </parent>
- <artifactId>microservice-config-client-refresh</artifactId>
- <packaging>jar</packaging>
- <properties>
- <project.build.sourceEncoding>UTF-</project.build.sourceEncoding>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-config</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <!-- 配置自动刷新的依赖 -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-bus-amqp</artifactId>
- </dependency>
- </dependencies>
- </project>
微服务之间的事务是分布式的事务(TCC,可靠事务的补偿机制,最大努力型事务)。Eureka,zk,consul,etcd都是做服务发现的话是一样的不同的产品而已。使用docker可以一次性启动所有的微服务,java -jar一次只能启动一个微服务。
调用链尽可能短,否则会出现超时。
微服务之间可以通过http或者rpc方式调用。SOAP协议很重,微服务之间的可以跨平台或者跨语言的。
客户端侧负载均衡:客户端可以算出来命中哪个服务端,那么服务端就没必要做负载均衡了。
nanoservices:比微服务更小的纳米服务框架。
Sidecar : 组件。
springcloud21---Config-bus实现配置自动刷新的更多相关文章
- spring cloud 系列第8篇 —— config+bus 分布式配置中心与配置热刷新 (F版本)
源码Gitub地址:https://github.com/heibaiying/spring-samples-for-all 一.config 简介 spring cloud config 分为服务端 ...
- SpringCloud Config(配置中心)实现配置自动刷新(十六)
一.实现原理 1.ConfigServer(配置中心服务端)从远端git拉取配置文件并在本地git一份,ConfigClient(微服务)从ConfigServer端获取自己对应 配置文件: 2.当远 ...
- SpringCloud学习之Bus消息总线实现配置自动刷新(九)
前面两篇文章我们聊了Spring Cloud Config配置中心,当我们在更新github上面的配置以后,如果想要获取到最新的配置,需要手动刷新或者利用webhook的机制每次提交代码发送请求来刷新 ...
- Spring Cloud 学习 之 Spring Cloud Bus实现修改远程仓库后配置自动刷新
版本号: Spring Boot:2.1.3.RELEASE Spring Cloud:G版 开发工具:IDEA 搭建配置中心,这里我们搭建一个简单版的就行 POM: <?xml ...
- Sublime3和Chrome配置自动刷新网页【实测可用】
SublimeText2下的LiveReload在SublimeText3下无法正常使用,本文整理SublimeText3安装LiveReload的方法.win7下实测可用! 安装成功后,就不需要再手 ...
- Spring Cloud(Dalston.SR5)--Config 集群配置中心-刷新配置
远程 SVN 服务器上面的配置修改后,需要通知客户端来改变配置,需要增加 spring-boot-starter-actuator 依赖并将 management.security.enabled 设 ...
- Spring Cloud 入门教程(三): 配置自动刷新
之前讲的配置管理, 只有在应用启动时会读取到GIT的内容, 之后只要应用不重启,GIT中文件的修改,应用无法感知, 即使重启Config Server也不行. 比如上一单元(Spring Cloud ...
- SpringBoot整合Nacos自动刷新配置
目的 Nacos作为SpringBoot服务的注册中心和配置中心. 在NacosServer中修改配置文件,在SpringBoot不重启的情况下,获取到修改的内容. 本例将在配置文件中配置一个 cml ...
- 史上最全Spring Cloud Alibaba--Nacos教程(涵盖负载均衡、配置管理、多环境切换、配置共享/刷新、灰度、集群)
能够实现Nacos安装 基于Nacos能实现应用负载均衡 能基于Nacos实现配置管理 配置管理 负载均衡 多环境切换 配置共享 配置刷新 灰度发布 掌握Nacos集群部署 1 Nacos安装 Nac ...
随机推荐
- Gamma编码及Delta编码概述
一.Elias Gamma Coding 即Gamma编码,是一种对正整数进行编码的统一编码,由Peter Elias发明.适用于预先无法获知最大编码整数的情况,而且小整数出现频率高,大整数出现频率低 ...
- Android之ListView分页数据加载
1.效果如下: 实例如下: 上图的添加数据按钮可以换成一个进度条 因为没有数据所以我加了一个按钮添加到数据库用于测试:一般在服务器拉去数据需要一定的时间,所以可以弄个进度条来提示用户: 点击加载按 ...
- Hadoop DBOutputFormat的使用
最近在研究数据在HDFS和关系型数据库之间的迁移,主要使用了两种方式:一是,按照数据库要求的文件格式生成文件,然后由数据库提供的导入工具进行导入:二是采用JDBC的方式进行导入.MapReduce默认 ...
- 详解struts2中配置action的方法
如何解决action太多的问题??我们因为需要不同的方法,所以往往建立很多不同的类,但是每个类中往往仅仅几行代码,不仅浪费了时间,而且配置起来也很繁琐,所以,建立一个共有的类,然后根据以下方式来操作, ...
- crossdomain.xml跨域配置文件的安全注意事项
零.绪论: 对WEB中的FLASH确实了解不多,对程序中的跨域配置也了解不多,这是自己以前写的一篇笔记,到现在也还了解不深,勉强记下来罢了,备忘. 一.什么是crossdomain.xml?这是一个f ...
- 如何学习 cocos2d-x ?
发表于 04/23/2014 作者 zrong — 24 条评论 ↓ 11,687 次查看 本站文章除注明转载外,均为本站原创或者翻译. 本站文章欢迎各种形式的转载,但请18岁以上的转载者注明文章出处 ...
- c# winform窗体边框风格的设计
1.首先,窗体的FormBorderStyle设置成None,不要控制边框. 2.然后,TransparencyKey和BackColor颜色设置成相同的,这样,窗体就透明了. 3.最后,窗体的拖动 ...
- 批量远程执行linux服务器程序--基于pxpect(多进程、记日志版)
#!/usr/bin/python '''Created on 2015-06-09@author: Administrator''' import pexpect import os,sys fro ...
- numeric_limits 模板的相关知识点
说白了,它是一个模板类,它主要是把C++当中的一些内建型别进行了封装,比如说numeric_limits<int>是一个特化后的类,从这个类的成员变量与成员函数中,我们可以了解到int的很 ...
- postgresql----SELECT
示例1.简单查询 使用*查询表所有的字段,也可以指定字段名查询 test=# select * from tbl_insert; a | b ---+---- | sd | ff ( rows) te ...