Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ARCH-doc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈文顺
ARCH-doc
Commits
c6905a0e
Commit
c6905a0e
authored
Mar 29, 2019
by
陈文顺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial commit
parents
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
0 deletions
+160
-0
apollo接入.md
+142
-0
分布式任务调度中心.md
+18
-0
No files found.
apollo接入.md
0 → 100644
View file @
c6905a0e
## apollo 接入
## apollo 接入
### 介绍

随着程序功能的日益复杂,程序的配置日益增多:各种功能的开关、参数的配置、服务器的地址……
对程序配置的期望值也越来越高:配置修改后实时生效,灰度发布,分环境、分集群管理配置,完善的权限、审核机制……
在这样的大环境下,传统的通过配置文件、数据库等方式已经越来越无法满足开发人员对配置管理的需求。
Apollo配置中心应运而生!
#### Apollo支持4个维度管理Key-Value格式的配置:
1.
application (应用) (订单服务,券码服务.....)
2.
environment (环境)(DEV、FAT、UAT、PRO)
3.
cluster (集群)
4.
namespace (命名空间) (application)
## 接入步骤
#### 第一步 再apollo创建应用的配置,可以copy现有的配置文件

#### 第二步 maven 依赖
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-client
</artifactId>
<version>
1.1.0
</version>
</dependency>
#### 第三步
spring 启动类加上注解@EnableApolloConfig
```
java
@SpringBootApplication
@ComponentScan
(
basePackages
=
"com.freemud, cn.freemud"
)
@MapperScan
(
basePackages
=
"com.freemud.demo.mapper"
)
//@EnableEurekaClient
@EnableApolloConfig
public
class
SpringbootDemoApplication
extends
WebMvcConfigurerAdapter
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
SpringbootDemoApplication
.
class
,
args
);
}
@Bean
public
HttpMessageConverter
getConverter
(){
return
new
FastJsonpHttpMessageConverter4
();
}
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
)
.
allowedOrigins
(
"*"
)
.
allowCredentials
(
true
)
.
allowedMethods
(
"GET"
,
"POST"
,
"DELETE"
,
"PUT"
,
"PATCH"
)
.
maxAge
(
3600
);
}
}
```
#### 参数设置
##### 1) AppId
Spring Boot的application.properties文件配置,如
```
app.id=YOUR-APP-ID
```
##### 2)Apollo Meta Server
可以在Spring Boot的application.properties中指定,不同环境地址不同
```
apollo.meta=http://config-service-url
```
##### 3)本地缓存路径
可以在Spring Boot的application.properties中指定
```
apollo.cacheDir=/opt/data/some-cache-dir
```
#### 第四步 骤代码中使用
```
//第一种方式
@Value("${timeout:100}")
private int timeout;
@Value("${swagger_enable:false}")
String swaggerEnable;
//第二种方式
@ApolloConfig
private Config config; //inject config for namespace application
public void someMethed(){
//获取配置
String value = config.getProperty(someKey, someDefaultValue);
}
//可以监听配置变化
@ApolloConfigChangeListener
public void onChange(ConfigChangeEvent changeEvent){
System.out.println(changeEvent.changedKeys());
}
```
DEV
开发环境
FAT
测试环境,相当于alpha环境(功能测试)
UAT
集成环境,相当于beta环境(回归测试)
PRO
生产环境
配置可以有多种加载方式
配置也有很多种加载方式,常见的有程序内部hard code,配置文件,环境变量,启动参数,基于数据库等
如果Apollo部署在公有云上,本地开发环境无法连接,但又需要做开发测试的话,客户端可以升级到0.11.0版本及以上,然后通过-Dapollo.configService=http://config-service的公网IP:端口来跳过meta service的服务发现
\ No newline at end of file
分布式任务调度中心.md
0 → 100644
View file @
c6905a0e
## 分布式任务调度中心
## 分布式任务调度中心
测试环境管理地址:
[
http://172.81.206.37:9505/cron-job-queue.htm
](
http://172.81.206.37:9505/cron-job-queue.htm
)
帐号:admin/admin
经过saas生产环境一段时间的试用,推荐给大家
采用开源lts经过简单扩展(实现通用任务触发器)
特点:对现有系统无任何侵入,不需要引入第三方库,不需要增加任何配置项;
使用方只需要提供一个接口地址,任务调度中心会根据你的配置(cron表达式)定时调用接口地址,达到定时任务的目的。
## 操作界面


\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment