Browse Source

增加seata不同环境的地址配置

test
smallchill 5 years ago
parent
commit
cbd2201a0c
  1. 32
      blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java
  2. 2
      blade-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java

32
blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java

@ -62,6 +62,21 @@ public interface LauncherConstant {
*/
String SENTINEL_TEST_ADDR = "172.30.0.58:8858";
/**
* seata dev 地址
*/
String SEATA_DEV_ADDR = "127.0.0.1:8091";
/**
* seata prod 地址
*/
String SEATA_PROD_ADDR = "172.30.0.68:8091";
/**
* seata test 地址
*/
String SEATA_TEST_ADDR = "172.30.0.68:8091";
/**
* dbuuo提供者
*/
@ -171,4 +186,21 @@ public interface LauncherConstant {
}
}
/**
* 动态获取seata地址
*
* @param profile 环境变量
* @return addr
*/
static String seataAddr(String profile) {
switch (profile) {
case (AppConstant.PROD_CODE):
return SEATA_PROD_ADDR;
case (AppConstant.TEST_CODE):
return SEATA_TEST_ADDR;
default:
return SEATA_DEV_ADDR;
}
}
}

2
blade-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java

@ -49,6 +49,8 @@ public class LauncherServiceImpl implements LauncherService {
PropsUtil.setProperty(props, "dubbo.version", AppConstant.APPLICATION_VERSION);
PropsUtil.setProperty(props, "dubbo.scan.base-packages", AppConstant.BASE_PACKAGES);
// seata注册地址
PropsUtil.setProperty(props, "seata.service.grouplist.default", LauncherConstant.seataAddr(profile));
// seata注册group格式
PropsUtil.setProperty(props, "seata.tx-service-group", LauncherConstant.seataServiceGroup(appName));
// seata配置服务group

Loading…
Cancel
Save