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 ...
随机推荐
- Ubuntu13.10:[3]如何开启SSH SERVER服务
作为最新版本的UBUNTU系统而言,开源,升级全部都不在话下.传说XP已经停止补丁更新了,使用UBUNTU也是一个很好的选择.ubuntu默认安装完成后只有ssh-agent(客户端模式),宾哥百度经 ...
- js array.filter实例(数组去重)
语法: 循环对数组中的元素调用callback函数, 如果返回true 保留,如果返回false 过滤掉, 返回新数组,老数组不变 var new_array = source_array.filt ...
- 解决 ssh 登录到ubuntu server 慢的问题
最近在服务器上使用ubuntu系统,服务器上开启sshd服务,在客户端处使用ssh登录到服务器的时候出现卡顿的现象. 在网上搜索了解决方案,主要是: 1. 修改服务器的 /etc/ssh/sshd_c ...
- 使用Java对文件进行解压缩
最近在一个项目中需要对文件进行自动的解压缩,Java提供了这种支持,还是挺好用的. 工具包封装在java.util.zip中. 1.首先是多个文件压缩成一个ZIP文件 思路:用一个ZipOutputS ...
- 使用Android Studio调试内存问题
http://blog.csdn.net/yutao52shi/article/details/50055669 前言 内存问题对于Android开发者是永远的痛.如果一个android程序员说他没有 ...
- bootstrap+html5+css3
一.栅格和块阴影 <!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 堆叠的水平</title ...
- 域渗透学习预备知识-IPC$的入侵防御
一.什么是IPC$ 以下段落引文自:http://www.xfocus.net/articles/200303/493.html IPC$(Internet Process Connection)是共 ...
- 正则表达式—RegEx(RegularExpressio)(三)
今日随笔,继续写一点关于正则表达式的 知识.前两天介绍了正则表达式验证匹配,提取等一些基本的知识,今天继续分享下它的另一个强大的应用:替换(replace). 开始之前,还是要补一下昨天的内容. 在我 ...
- img通过canvas转成base64编码
<script type="text/javascript"> function getBase64Image(img) { var canvas = document ...
- iOS5 ARC学习笔记:strong、weak等详解
2013-03-25 13:41 佚名 oschina 字号:T | T iOS5中加入了新知识,就是ARC,其实我并不是很喜欢它,因为习惯了自己管理内存.但是学习还是很有必要的.现在我们看看iOS5 ...