原文:http://blog.csdn.net/qq_18675693/article/details/53337941

微服务:spring-cloud-archaius 起步

原创 2016年11月25日 18:13:05
  • 4596

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 起步的更多相关文章

  1. 微服务 | Spring Cloud(一):从单体SSM 到 Spring Cloud

    系列文章目录 微服务 | Spring Cloud(一):从单体SSM 到 Spring Cloud 目录 系列文章目录 前言 单体式架构 微服务架构 优点 缺点 服务发现与弹性扩展 参考 前言 在微 ...

  2. 微服务Spring Cloud与Kubernetes比较

    转 http://www.tuicool.com/articles/VnMf2y3 Spring Cloud或Kubernetes都宣称它们是开发运行微服务的最好环境,哪个更好?答案是两个都是,但他们 ...

  3. 微服务&spring cloud架构系列汇总

    为了方便查找,把微服务&微服务架构之spring cloud架构系列文章按时间正序整理了一下,记录如下:   1. 微服务架构之spring cloud 介绍 2. 微服务架构之spring ...

  4. SpringCloud---消息驱动的微服务---Spring Cloud Stream

    1.概述 1.1 Spring Cloud Stream:用来   为微服务应用   构建   消息驱动能力的框架: 可基于SpringBoot来创建独立.可用于生产的Spring应用程序: 使用Sp ...

  5. 网关服务Spring Cloud Gateway(二)

    上一篇文章服务网关 Spring Cloud GateWay 初级篇,介绍了 Spring Cloud Gateway 的相关术语.技术原理,以及如何快速使用 Spring Cloud Gateway ...

  6. 网关服务Spring Cloud Gateway(一)

    Spring 官方最终还是按捺不住推出了自己的网关组件:Spring Cloud Gateway ,相比之前我们使用的 Zuul(1.x) 它有哪些优势呢?Zuul(1.x) 基于 Servlet,使 ...

  7. SpringCloud---API网关服务---Spring Cloud Zuul

    1.概述 1.1 微服务架构出现的问题   及  解决: 1.1.1 前言 每个微服务应用都提供对外的Restful API服务,它通过F5.Nginx等网络设备或工具软件实现对各个微服务的路由与负载 ...

  8. 网关服务Spring Cloud Gateway(三)

    上篇文章介绍了 Gataway 和注册中心的使用,以及 Gataway 中 Filter 的基本使用,这篇文章我们将继续介绍 Filter 的一些常用功能. 修改请求路径的过滤器 StripPrefi ...

  9. Consul集群加入网关服务(Spring Cloud Gateway)

    Consul集群加入网关服务 架构示意图 外部的应用或网站通过外部网关服务消费各种服务,内部的生产者本身也可能是消费者,内部消费行为通过内部网关服务消费. 一个内部网关和一个外部网关以及一个Consu ...

  10. 网关服务spring cloud zuul

    Zuul例子配置文件 spring.application.name=switch-gateway server.port=5555 请求路由 传统路由方式 zuul.routes.api-a-url ...

随机推荐

  1. 2017多校第6场 HDU 6097 Mindis 计算几何,圆的反演

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6097 题意:有一个圆心在原点的圆,给定圆的半径,给定P.Q两点坐标(PO=QO,P.Q不在圆外),取圆 ...

  2. ArcGIS Server配置端口

    写在前面,GIS服务器必须连通到外网,基于某些情况,可能一个机组有多态服务器,担任不同的角色,有Web服务器.数据库服务器和GIS服务器等,但是可能购买时只有一个外网IP,这样是不行的.JS脚本运行在 ...

  3. redis之(一)redis的简单介绍

    [一]:概念 --->Redis是一个开源的,高性能的,基于键值对的缓存与存储系统 --->Redis数据库中的多有数据都存储在内存中,由于内存的读写速度远快于硬盘,一秒读写超过10万键值 ...

  4. hdu 2448(KM算法+SPFA)

    Mining Station on the Sea Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  5. LeetCode Binary Tree PostorderTranversal

    Problem Description Given a binary tree, return the postorder traversal of its nodes' values. For ex ...

  6. zookeeper编程入门系列之zookeeper实现分布式进程监控和分布式共享锁(图文详解)

    本博文的主要内容有 一.zookeeper编程入门系列之利用zookeeper的临时节点的特性来监控程序是否还在运行   二.zookeeper编程入门系列之zookeeper实现分布式进程监控 三. ...

  7. ZIP排除指定目录进行压缩

    zip -r glog-0.3.5.zip glog-0.3.5/  -x "glog-0.3.5/doc/*" unzip -v glog-0.3.5.zip 进行查看ZIP的内 ...

  8. try catch finally 执行顺序面试题总结

    在网上看到一些异常处理的面试题,试着总结一下,先看下面代码,把这个方法在main中进行调用打印返回结果,看看结果输出什么. public static int testBasic(){ int i = ...

  9. 归并排序(MergeSort)

    原帖:http://blog.csdn.net/magicharvey/article/details/10192933 算法描述 归并排序(MergeSort)是采用分治法的一个非常典型的应用.通过 ...

  10. Linux操作命令(六)

    本次实验将介绍 Linux 命令中 wc 和 grep 命令的用法. wc grep 1.wc wc命令是一个统计的工具,主要用来显示文件所包含的行.字和字节数. wc命令是word count的缩写 ...