Commit 0b8091ffcc9686407f75968f0184407c6e086c01
1 parent
ce54e482
feature(*): 对接配置中心
- 对接配置中心
Showing
19 changed files
with
129 additions
and
83 deletions
fw-hermes-domain/src/main/java/cn/fw/hermes/domain/xinge/XinGeProfile.kt
0 → 100644
1 | +package cn.fw.hermes.domain.xinge | |
2 | + | |
3 | +/** | |
4 | + * 信鸽配置文件 | |
5 | + * | |
6 | + * @author : kurisu | |
7 | + * @version : 1.0 | |
8 | + * @desc : 信鸽配置文件 | |
9 | + * @date : 2023-12-29 16:58 | |
10 | + */ | |
11 | +data class XinGeProfile( | |
12 | + val appId: String?, | |
13 | + val secretKey: String?, | |
14 | + val connectTimeOut: Int?, | |
15 | + val readTimeOut: Int?, | |
16 | + val domainUrl: String? | |
17 | +) | ... | ... |
fw-hermes-server/pom.xml
... | ... | @@ -14,16 +14,8 @@ |
14 | 14 | |
15 | 15 | <dependencies> |
16 | 16 | <dependency> |
17 | - <groupId>com.nepxion</groupId> | |
18 | - <artifactId>discovery-plugin-starter-nacos</artifactId> | |
19 | - </dependency> | |
20 | - <dependency> | |
21 | - <groupId>com.nepxion</groupId> | |
22 | - <artifactId>discovery-plugin-config-center-starter-nacos</artifactId> | |
23 | - </dependency> | |
24 | - <dependency> | |
25 | - <groupId>com.nepxion</groupId> | |
26 | - <artifactId>discovery-plugin-strategy-starter-service</artifactId> | |
17 | + <groupId>com.alibaba.cloud</groupId> | |
18 | + <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> | |
27 | 19 | </dependency> |
28 | 20 | <!-- spring --> |
29 | 21 | <dependency> | ... | ... |
fw-hermes-server/src/main/java/cn/fw/hermes/config/AutoConfiguration.kt
... | ... | @@ -9,6 +9,7 @@ import org.eclipse.paho.client.mqttv3.MqttAsyncClient |
9 | 9 | import org.eclipse.paho.client.mqttv3.MqttException |
10 | 10 | import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence |
11 | 11 | import org.springframework.boot.context.properties.EnableConfigurationProperties |
12 | +import org.springframework.cloud.context.config.annotation.RefreshScope | |
12 | 13 | import org.springframework.context.annotation.Bean |
13 | 14 | import org.springframework.context.annotation.Configuration |
14 | 15 | |
... | ... | @@ -17,6 +18,7 @@ import org.springframework.context.annotation.Configuration |
17 | 18 | * |
18 | 19 | * @author kurisu |
19 | 20 | */ |
21 | +@RefreshScope | |
20 | 22 | @Configuration |
21 | 23 | @EnableConfigurationProperties(MqttProperty::class, SettingProperty::class, XinGeProperty::class) |
22 | 24 | class AutoConfiguration(private val mqttProperty: MqttProperty) { | ... | ... |
fw-hermes-server/src/main/java/cn/fw/hermes/controller/erp/XinGeDebugController.kt
0 → 100644
1 | +package cn.fw.hermes.controller.erp | |
2 | + | |
3 | +import cn.fw.common.web.annotation.ControllerMethod | |
4 | +import cn.fw.common.web.util.ResultBuilder.success | |
5 | +import cn.fw.data.base.domain.common.Message | |
6 | +import cn.fw.hermes.domain.xinge.XinGeProfile | |
7 | +import cn.fw.hermes.service.property.XinGeProperty | |
8 | +import cn.fw.security.auth.client.annotation.Authorization | |
9 | +import cn.fw.security.auth.client.enums.AuthType | |
10 | +import lombok.RequiredArgsConstructor | |
11 | +import org.springframework.validation.annotation.Validated | |
12 | +import org.springframework.web.bind.annotation.GetMapping | |
13 | +import org.springframework.web.bind.annotation.RequestMapping | |
14 | +import org.springframework.web.bind.annotation.RestController | |
15 | + | |
16 | +/** | |
17 | + * 信鸽debug类 | |
18 | + * | |
19 | + * @author : kurisu | |
20 | + * @version : 1.0 | |
21 | + * @desc : 信鸽debug类 | |
22 | + * @date : 2023-12-29 16:43 | |
23 | + */ | |
24 | +@Validated | |
25 | +@RestController | |
26 | +@RequestMapping("/debug/xinge") | |
27 | +@RequiredArgsConstructor | |
28 | +@Authorization(AuthType.NONE) | |
29 | +class XinGeDebugController(private val xinGeProperty: XinGeProperty) { | |
30 | + @ControllerMethod("获取信鸽相关配置") | |
31 | + @GetMapping("/property/domain") | |
32 | + fun getTopics(): Message<XinGeProfile> { | |
33 | + val profile = xinGeProperty.run { | |
34 | + XinGeProfile(appId, secretKey, connectTimeOut, readTimeOut, domainUrl) | |
35 | + } | |
36 | + return success(profile) | |
37 | + } | |
38 | +} | ... | ... |
fw-hermes-server/src/main/java/cn/fw/hermes/task/MessageManaTask.kt
... | ... | @@ -2,6 +2,7 @@ package cn.fw.hermes.task |
2 | 2 | |
3 | 3 | import cn.fw.hermes.service.biz.MessageManaBizService |
4 | 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty |
5 | +import org.springframework.cloud.context.config.annotation.RefreshScope | |
5 | 6 | import org.springframework.scheduling.annotation.Scheduled |
6 | 7 | import org.springframework.stereotype.Component |
7 | 8 | import java.time.LocalDate |
... | ... | @@ -15,6 +16,7 @@ import java.time.LocalDate |
15 | 16 | * @date : 2023-07-24 15:44 |
16 | 17 | */ |
17 | 18 | @Component |
19 | +@RefreshScope | |
18 | 20 | @ConditionalOnProperty(prefix = "task", name = ["switch"], havingValue = "on") |
19 | 21 | class MessageManaTask(private val messageManaBizService: MessageManaBizService) { |
20 | 22 | /** | ... | ... |
fw-hermes-server/src/main/java/cn/fw/hermes/task/MessageSaveTask.kt
... | ... | @@ -9,6 +9,7 @@ import cn.fw.hermes.service.biz.MsgPrepareBizService |
9 | 9 | import cn.fw.hermes.service.data.MessageDataService |
10 | 10 | import cn.hutool.json.JSONUtil |
11 | 11 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty |
12 | +import org.springframework.cloud.context.config.annotation.RefreshScope | |
12 | 13 | import org.springframework.data.redis.core.StringRedisTemplate |
13 | 14 | import org.springframework.scheduling.annotation.Async |
14 | 15 | import org.springframework.scheduling.annotation.Scheduled |
... | ... | @@ -26,6 +27,7 @@ import java.util.concurrent.CompletableFuture |
26 | 27 | * @date : 2023-07-24 15:05 |
27 | 28 | */ |
28 | 29 | @Component |
30 | +@RefreshScope | |
29 | 31 | @ConditionalOnProperty(prefix = "task", name = ["switch"], havingValue = "on") |
30 | 32 | class MessageSaveTask( |
31 | 33 | private val stringRedisTemplate: StringRedisTemplate, |
... | ... | @@ -90,5 +92,4 @@ class MessageSaveTask( |
90 | 92 | stringRedisTemplate.opsForList().rightPushAll(Constant.CACHE_PERSISTENT_MSG_CACHE_KEY, failList) |
91 | 93 | } |
92 | 94 | } |
93 | - | |
94 | 95 | } | ... | ... |
fw-hermes-server/src/main/java/cn/fw/hermes/task/MessageSendTask.kt
... | ... | @@ -10,6 +10,7 @@ import cn.fw.hermes.service.data.MessageHistoryService |
10 | 10 | import com.baomidou.mybatisplus.core.toolkit.Wrappers |
11 | 11 | import org.springframework.beans.factory.annotation.Autowired |
12 | 12 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty |
13 | +import org.springframework.cloud.context.config.annotation.RefreshScope | |
13 | 14 | import org.springframework.data.redis.core.StringRedisTemplate |
14 | 15 | import org.springframework.scheduling.annotation.Async |
15 | 16 | import org.springframework.scheduling.annotation.Scheduled |
... | ... | @@ -26,6 +27,7 @@ import java.time.LocalDateTime |
26 | 27 | * @date : 2023-07-24 15:44 |
27 | 28 | */ |
28 | 29 | @Component |
30 | +@RefreshScope | |
29 | 31 | @ConditionalOnProperty(prefix = "task", name = ["switch"], havingValue = "on") |
30 | 32 | class MessageSendTask @Autowired constructor( |
31 | 33 | private val stringRedisTemplate: StringRedisTemplate, | ... | ... |
fw-hermes-server/src/main/resources/application-dev.yml deleted
1 | -spring: | |
2 | - cloud: | |
3 | - nacos: | |
4 | - discovery: | |
5 | - metadata: | |
6 | - group: discovery-dev-group | |
7 | - region: dev | |
8 | - version: 1.0 | |
9 | - namespace: df959b8c-de58-4d02-b9fb-d65ca3be05f3 | |
10 | -nacos: | |
11 | - plugin: | |
12 | - namespace: df959b8c-de58-4d02-b9fb-d65ca3be05f3 | |
13 | - | |
14 | -p6spy-db: | |
15 | - url: jdbc:p6spy:mysql://192.168.0.234:3306/fw_hermes?characterEncoding=UTF-8&useSSL=false |
fw-hermes-server/src/main/resources/bootstrap.yml
0 → 100644
1 | +spring: | |
2 | + application: | |
3 | + name: fw-hermes | |
4 | + main: | |
5 | + allow-bean-definition-overriding: true | |
6 | + profiles: | |
7 | + active: ${activatedProfiles} | |
8 | + cloud: | |
9 | + nacos: | |
10 | + server-addr: ${spring.nacos.address} | |
11 | + discovery: | |
12 | + namespace: ${spring.nacos.namespace} | |
13 | + config: | |
14 | + enabled: true | |
15 | + file-extension: yaml | |
16 | + namespace: ${spring.nacos.namespace} | |
17 | + | |
18 | +#--- 环境分隔符 | |
19 | +--- | |
20 | +spring: | |
21 | + profiles: local | |
22 | + application: | |
23 | + name: fw-hermes | |
24 | + cloud: | |
25 | + nacos: | |
26 | + discovery: | |
27 | + metadata: | |
28 | + grayTag: kurisu | |
29 | +--- | |
30 | +spring: | |
31 | + profiles: dev | |
32 | + nacos: | |
33 | + address: 172.26.154.169:8848 | |
34 | + namespace: df959b8c-de58-4d02-b9fb-d65ca3be05f3 | |
35 | +--- | |
36 | +spring: | |
37 | + profiles: test | |
38 | + nacos: | |
39 | + address: 172.26.154.169:8848 | |
40 | + namespace: 0ba6d5d6-2a49-4086-b6c3-dbeec01c61a4 | |
41 | +--- | |
42 | +spring: | |
43 | + profiles: prd | |
44 | + nacos: | |
45 | + address: 192.168.0.91:8848 | |
46 | + namespace: | ... | ... |
fw-hermes-server/src/main/resources/logback-spring.xml
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <!--引入默认的一些设置--> |
4 | 4 | <property name="charSet" value="UTF-8"/> |
5 | 5 | |
6 | - <springProfile name="prd,gray,test,dev"> | |
6 | + <springProfile name="prd,gray,test,dev,local"> | |
7 | 7 | <include resource="logfile.xml"/> |
8 | 8 | </springProfile> |
9 | 9 | |
... | ... | @@ -45,4 +45,4 @@ |
45 | 45 | <appender-ref ref="CONSOLE"/> |
46 | 46 | </root> |
47 | 47 | </springProfile> |
48 | -</configuration> | |
49 | 48 | \ No newline at end of file |
49 | +</configuration> | ... | ... |
fw-hermes-server/temp/application-dev.yml
0 → 100644
fw-hermes-server/src/main/resources/application-gray.yml renamed to fw-hermes-server/temp/application-gray.yml
1 | 1 | spring: |
2 | - cloud: | |
3 | - nacos: | |
4 | - discovery: | |
5 | - metadata: | |
6 | - group: discovery-gray-group | |
7 | - region: gray | |
8 | - version: 1.0 | |
9 | - server-addr: 192.168.0.91:8848 | |
10 | 2 | datasource: |
11 | 3 | url: jdbc:mysql://192.168.0.101:3306/fw_hermes?characterEncoding=UTF-8&useSSL=false |
12 | 4 | username: root |
13 | 5 | password: Feewee@root123 |
14 | 6 | redis: |
15 | 7 | host: 192.168.0.101 |
16 | -nacos: | |
17 | - server-addr: 192.168.0.91:8848 | |
18 | 8 | rocketmq: |
19 | 9 | name-server: 192.168.0.91:9876 |
20 | 10 | |
... | ... | @@ -23,5 +13,5 @@ mqtt: |
23 | 13 | port: 1883 |
24 | 14 | |
25 | 15 | xinge: |
26 | - appId: 1500039173 | |
27 | - secretKey: 1dcfb0e6b12e96c6aaec790ac9d89323 | |
16 | + appId: 1500039173 | |
17 | + secretKey: 1dcfb0e6b12e96c6aaec790ac9d89323 | ... | ... |
fw-hermes-server/src/main/resources/application-local.yml renamed to fw-hermes-server/temp/application-local.yml
1 | -nacos: | |
2 | - plugin: | |
3 | - namespace: df959b8c-de58-4b02-b9fb-d65ca3be05f3 | |
4 | - | |
5 | 1 | spring: |
6 | 2 | cloud: |
7 | 3 | inetutils: |
8 | 4 | preferred-networks: |
9 | 5 | - 10.8 |
10 | - nacos: | |
11 | - discovery: | |
12 | - metadata: | |
13 | - grayTag: kurisu | |
14 | 6 | application: |
15 | - name: fw-hermes | |
7 | + name: fw-hermes-local | |
16 | 8 | |
17 | 9 | datasource: |
18 | 10 | hikari: |
... | ... | @@ -23,4 +15,4 @@ mqtt: |
23 | 15 | clientId: hermes |
24 | 16 | |
25 | 17 | task: |
26 | - switch: 'off' | |
18 | + switch: 'off' | ... | ... |
fw-hermes-server/src/main/resources/application-prd.yml renamed to fw-hermes-server/temp/application-prd.yml
1 | 1 | spring: |
2 | - cloud: | |
3 | - nacos: | |
4 | - discovery: | |
5 | - metadata: | |
6 | - group: discovery-prd-group | |
7 | - region: prd | |
8 | - version: 1.0 | |
9 | - server-addr: 192.168.0.91:8848 | |
10 | 2 | datasource: |
11 | 3 | url: jdbc:mysql://192.168.0.101:3306/fw_hermes?characterEncoding=UTF-8&useSSL=false |
12 | 4 | username: root |
... | ... | @@ -17,8 +9,6 @@ logging: |
17 | 9 | file: |
18 | 10 | max-history: 15 |
19 | 11 | max-size: 1GB |
20 | -nacos: | |
21 | - server-addr: 192.168.0.91:8848 | |
22 | 12 | rocketmq: |
23 | 13 | name-server: 192.168.0.91:9876 |
24 | 14 | mqtt: |
... | ... | @@ -30,5 +20,5 @@ mqtt: |
30 | 20 | secret: SEC509e8cd6d0c3969563acf9e33c177c49cf2a365cd60ddc841d4eb728afcd6940 |
31 | 21 | |
32 | 22 | xinge: |
33 | - appId: 1500039173 | |
34 | - secretKey: 1dcfb0e6b12e96c6aaec790ac9d89323 | |
23 | + appId: 1500039173 | |
24 | + secretKey: 1dcfb0e6b12e96c6aaec790ac9d89323 | ... | ... |
fw-hermes-server/src/main/resources/application-test.yml renamed to fw-hermes-server/temp/application-test.yml
1 | 1 | spring: |
2 | - cloud: | |
3 | - nacos: | |
4 | - discovery: | |
5 | - server-addr: 172.26.154.169:8848 | |
6 | - metadata: | |
7 | - group: discovery-test-group | |
8 | - region: test | |
9 | - version: 1.0 | |
10 | - namespace: 0ba6d5d6-2a49-4086-b6c3-dbeec01c61a4 | |
11 | 2 | datasource: |
12 | 3 | password: mysql@pwd123 |
13 | 4 | url: jdbc:mysql://172.26.154.169:3301/fw_hermes?characterEncoding=UTF-8&useSSL=false |
... | ... | @@ -17,11 +8,6 @@ spring: |
17 | 8 | port: 6378 |
18 | 9 | password: fw@test@redis |
19 | 10 | |
20 | -nacos: | |
21 | - server-addr: 172.26.154.169:8848 | |
22 | - plugin: | |
23 | - namespace: 0ba6d5d6-2a49-4086-b6b3-dbeec01c61a4 | |
24 | - | |
25 | 11 | rocketmq: |
26 | 12 | name-server: 172.26.154.169:9876 |
27 | 13 | ... | ... |
fw-hermes-server/src/main/resources/application.yml renamed to fw-hermes-server/temp/application.yml
1 | 1 | spring: |
2 | - application: | |
3 | - name: fw-hermes | |
4 | 2 | cache: |
5 | 3 | locker: |
6 | 4 | key-prefix: 'hermes:locker:' |
... | ... | @@ -19,11 +17,6 @@ spring: |
19 | 17 | ttl: 15m |
20 | 18 | - name: rpc:ehr:mobile |
21 | 19 | ttl: 15m |
22 | - | |
23 | - cloud: | |
24 | - nacos: | |
25 | - discovery: | |
26 | - server-addr: 192.168.0.230:8848 | |
27 | 20 | datasource: |
28 | 21 | driver-class-name: com.mysql.jdbc.Driver |
29 | 22 | hikari: | ... | ... |
fw-hermes-service/pom.xml
... | ... | @@ -14,6 +14,10 @@ |
14 | 14 | |
15 | 15 | <dependencies> |
16 | 16 | <dependency> |
17 | + <groupId>com.alibaba.cloud</groupId> | |
18 | + <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> | |
19 | + </dependency> | |
20 | + <dependency> | |
17 | 21 | <groupId>org.springframework.retry</groupId> |
18 | 22 | <artifactId>spring-retry</artifactId> |
19 | 23 | </dependency> | ... | ... |
fw-hermes-service/src/main/java/cn/fw/hermes/service/biz/AppUpdateBizService.java
... | ... | @@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j; |
19 | 19 | import org.apache.commons.lang3.tuple.Pair; |
20 | 20 | import org.redisson.api.RLock; |
21 | 21 | import org.springframework.beans.factory.annotation.Value; |
22 | +import org.springframework.cloud.context.config.annotation.RefreshScope; | |
22 | 23 | import org.springframework.stereotype.Service; |
23 | 24 | import org.springframework.transaction.annotation.Transactional; |
24 | 25 | import org.springframework.util.CollectionUtils; |
... | ... | @@ -40,6 +41,7 @@ import static cn.fw.common.businessvalidator.Validator.BV; |
40 | 41 | */ |
41 | 42 | @Slf4j |
42 | 43 | @Service |
44 | +@RefreshScope | |
43 | 45 | @RequiredArgsConstructor |
44 | 46 | public class AppUpdateBizService { |
45 | 47 | private final AppUpdateMsgService appUpdateMsgService; | ... | ... |
fw-hermes-service/src/main/java/cn/fw/hermes/service/biz/CommonBizService.java
... | ... | @@ -20,6 +20,7 @@ import lombok.Getter; |
20 | 20 | import lombok.RequiredArgsConstructor; |
21 | 21 | import lombok.extern.slf4j.Slf4j; |
22 | 22 | import org.springframework.beans.factory.annotation.Value; |
23 | +import org.springframework.cloud.context.config.annotation.RefreshScope; | |
23 | 24 | import org.springframework.stereotype.Service; |
24 | 25 | import org.springframework.util.CollectionUtils; |
25 | 26 | |
... | ... | @@ -40,6 +41,7 @@ import static cn.fw.common.businessvalidator.Validator.BV; |
40 | 41 | @RequiredArgsConstructor |
41 | 42 | @Slf4j |
42 | 43 | @Service |
44 | +@RefreshScope | |
43 | 45 | public class CommonBizService { |
44 | 46 | private final SysPlatformService sysPlatformService; |
45 | 47 | private final SysTopicService sysTopicService; | ... | ... |