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 ...
随机推荐
- 编译OSG的FreeType插件时注意的问题
使用自己编译的freetype.lib,在编译osgdb_freetype插件项目时,报错LINK错误,找不到png的一堆函数 最简单的方式是不要使用PNG编译freetype.记住不要犯贱.
- SecureCRT 详细使用图文教程(按步骤)
一.安装和激活 安装 1.在http://www./softs/55471.html下载相关包激活工具,运行scrt622-x86.exe. 2.进入安装向导程序,默认下一步,直到安装完成既可以. 破 ...
- UITouch 的主要方法:
1. UITouch 的主要方法: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesM ...
- 价格战拉上了Android平板电脑
自从苹果iPad成功以来,平板电脑一直是人们争相追捧的热门产品.其中Android平板电脑已是遍地开花.去年,在移动行业,主流厂商已推出了太多各种款型的Android平板电脑,它们留给2014年的创新 ...
- LeetCode——Summary Ranges
Description: Given a sorted integer array without duplicates, return the summary of its ranges. For ...
- 从TCP三次握手说起–浅析TCP协议中的疑难杂症(2)
版权声明:本文由黄日成原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/108 来源:腾云阁 https://www.qclo ...
- 2015.10.9js(页面坐标)
关于js鼠标事件综合各大浏览器能获取到坐标的属性 1.page随滚动条变化(pageY会增加滚动条滚动的距离),兼容性:除IE6/7/8不支持外,其余浏览器均支持; 2.clientX/Y获取到的是触 ...
- Jetty源码学习-编译Jetty源码二三事
工作小几个月了,JDK基础和web应用框架学的的差不多了,开始学习Jetty源码,费了小半天才编译成功,把自己拆过的坑记录下来. 编译前的环境: MAVEN 3.3.Eclips eLuna Serv ...
- java定时器学习
一.这个是利用jdk自带的Thread类的sleep方法实现定时执行任务. package tasker; import java.util.Date; public class tasker01 e ...
- shell中的多进程【并发】(转)
http://bbs.51cto.com/thread-1104907-1-1.html