微服务:spring-cloud-archaius 起步
原文:http://blog.csdn.net/qq_18675693/article/details/53337941
微服务:spring-cloud-archaius 起步
Archaius是什么?
一句话:可以动态的管理属性配置文件。使用相关的API使用属性就可以实现动态的数性加载。
参考自Getting-Started
* 引入项目中*
<dependency>
<groupId>com.netflix.archaius</groupId>
<artifactId>archaius-core</artifactId>
<version>0.6.0</version>
</dependency>
- 1
- 2
- 3
- 4
- 5
使用本地配置文件作为配置源
- 默认的,Archaius将查找classpath下名为
config.properties文件并读取,这个配置文件可以使包含在一个jar包的根路径下。 - 另外,你可以使用属性
archaius.configurationSource.additionalUrls来包含url形式的文件,多个文件用逗号分割。
可以使用下面的API在程序中得到你需要的属性
// create a property whose value is type long and use 1000 as the default
// if the property is not defined
DynamicLongProperty timeToWait =
DynamicPropertyFactory.getInstance().getLongProperty("lock.waitTime", 1000);
// ...
ReentrantLock lock = ...;
// ...
lock.tryLock(timeToWait.get(), TimeUnit.MILLISECONDS); // timeToWait.get() returns up-to-date value of the property
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
默认的:Archaius会每一分钟去重新加载下属性配置
注意:配置多属性文件时的属性覆盖,最后读到的属性会覆盖前面相同的属性
列出我们可以修改的一些系统属性
| Operation | HTTP action | Notes |
| archaius.configurationSource.defaultFileName | 指定Archaius默认加载的配置源属性文件名,默认:classpath:config.properties | config.properties |
| archaius.fixedDelayPollingScheduler.initialDelayMills | 延迟加载,默认30秒 | 30000 |
| archaius.fixedDelayPollingScheduler.delayMills | 两次属性读取时间间隔,默认1分钟 | 60000 |
高级使用:自定义configuration source和polling scheduler,即自己设计动态属性配置方案。
微服务:spring-cloud-archaius 起步的更多相关文章
- 微服务 | Spring Cloud(一):从单体SSM 到 Spring Cloud
系列文章目录 微服务 | Spring Cloud(一):从单体SSM 到 Spring Cloud 目录 系列文章目录 前言 单体式架构 微服务架构 优点 缺点 服务发现与弹性扩展 参考 前言 在微 ...
- 微服务Spring Cloud与Kubernetes比较
转 http://www.tuicool.com/articles/VnMf2y3 Spring Cloud或Kubernetes都宣称它们是开发运行微服务的最好环境,哪个更好?答案是两个都是,但他们 ...
- 微服务&spring cloud架构系列汇总
为了方便查找,把微服务&微服务架构之spring cloud架构系列文章按时间正序整理了一下,记录如下: 1. 微服务架构之spring cloud 介绍 2. 微服务架构之spring ...
- SpringCloud---消息驱动的微服务---Spring Cloud Stream
1.概述 1.1 Spring Cloud Stream:用来 为微服务应用 构建 消息驱动能力的框架: 可基于SpringBoot来创建独立.可用于生产的Spring应用程序: 使用Sp ...
- 网关服务Spring Cloud Gateway(二)
上一篇文章服务网关 Spring Cloud GateWay 初级篇,介绍了 Spring Cloud Gateway 的相关术语.技术原理,以及如何快速使用 Spring Cloud Gateway ...
- 网关服务Spring Cloud Gateway(一)
Spring 官方最终还是按捺不住推出了自己的网关组件:Spring Cloud Gateway ,相比之前我们使用的 Zuul(1.x) 它有哪些优势呢?Zuul(1.x) 基于 Servlet,使 ...
- SpringCloud---API网关服务---Spring Cloud Zuul
1.概述 1.1 微服务架构出现的问题 及 解决: 1.1.1 前言 每个微服务应用都提供对外的Restful API服务,它通过F5.Nginx等网络设备或工具软件实现对各个微服务的路由与负载 ...
- 网关服务Spring Cloud Gateway(三)
上篇文章介绍了 Gataway 和注册中心的使用,以及 Gataway 中 Filter 的基本使用,这篇文章我们将继续介绍 Filter 的一些常用功能. 修改请求路径的过滤器 StripPrefi ...
- Consul集群加入网关服务(Spring Cloud Gateway)
Consul集群加入网关服务 架构示意图 外部的应用或网站通过外部网关服务消费各种服务,内部的生产者本身也可能是消费者,内部消费行为通过内部网关服务消费. 一个内部网关和一个外部网关以及一个Consu ...
- 网关服务spring cloud zuul
Zuul例子配置文件 spring.application.name=switch-gateway server.port=5555 请求路由 传统路由方式 zuul.routes.api-a-url ...
随机推荐
- sicily 1020. Big Integer
Description Long long ago, there was a super computer that could deal with VeryLongIntegers(no VeryL ...
- c++设计模式系列----factory模式
问题: 假设我们要开发一个游戏--打怪物,首先,游戏有分等级,假设有初级,中级两个个等级(就不用flappy bird模式了,那个比较特殊,对一个玩家来说是难以具有持久吸引力的!),不同的等级怪物也是 ...
- uoj#35 后缀排序(后缀数组模版)
#include<bits/stdc++.h> #define N 100005 using namespace std; char s[N]; int a[N],c[N],t1[N],t ...
- 运输层和TCP/IP协议
0. 基本要点 运输层是为相互通信的应用进程提供逻辑通信. 端口和套接字的意义 什么是无连接UDP 什么是面向连接的TCP 在不可靠的网络上实现可靠传输的工作原理,停止等待协议和ARQ协议 TCP的滑 ...
- 微信小程序滚动条返回顶部
scroll-view(可滚动视图区域): 使用竖向滚动时,需要给<scroll-view/>一个固定高度,通过 WXSS 设置 height,将scroll-y属性设置为true,将en ...
- vue 同页面不同参数
项目:详情页中有一个模块为更多产品,点击也是跳转到详情页,也就是相同路由,不同参数. 试过的方法:用this.$router.push,并没有任何反应,没有任何请求,页面也未重新加载,用this.$e ...
- 19:django 分页
分页是网站中比较常见的应用,django提供了一些类帮助管理分页的数据,这些类都位于django.core.paginator.py文件里面 分页类 构造函数 class Paginator(obje ...
- sharding-JDBC 实现读写分离
需求 一主两从,做读写分离. 多个从库之间实现负载均衡. 可手动强制部分读请求到主库上.(因为主从同步有延迟,对实时性要求高的系统,可以将部分读请求也走主库) 本次不讨论 MySQL如何配置主从同步相 ...
- 《逐梦旅程 WINDOWS游戏编程之从零开始》笔记10——三维天空的构建&三维粒子的实现&多游戏模型的载入
第23章 三维天空的构建 目前描述三维天空的技术主要包括三种类型,直接来介绍使用最广泛的模拟技术,详细的描述可以见作者的博文. 天空盒(Sky Box),即放到场景的是一个立方体.它是目前使用最广泛的 ...
- Word Search——经典题(还没细看)
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from l ...