From 18d25a4fd6d7693014a7d6321dad4f384328d84d Mon Sep 17 00:00:00 2001 From: zhanggougou <15651908511@163.com> Date: Fri, 25 Apr 2025 14:55:46 +0800 Subject: [PATCH] =?UTF-8?q?[fire-1223]=20=E9=85=8D=E7=BD=AE=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zto/fire/common/conf/FireFrameworkConf.scala | 8 ++++++++ .../zto/fire/common/util/ConfigurationCenterManager.scala | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fire-common/src/main/scala/com/zto/fire/common/conf/FireFrameworkConf.scala b/fire-common/src/main/scala/com/zto/fire/common/conf/FireFrameworkConf.scala index f3ab42d..5238020 100644 --- a/fire-common/src/main/scala/com/zto/fire/common/conf/FireFrameworkConf.scala +++ b/fire-common/src/main/scala/com/zto/fire/common/conf/FireFrameworkConf.scala @@ -107,6 +107,10 @@ private[fire] object FireFrameworkConf { lazy val FIRE_CONFIG_CENTER_REGISTER_CONF_PROD_ADDRESS = "fire.config_center.register.conf.prod.address" // 配置中心测试环境注册地址 lazy val FIRE_CONFIG_CENTER_REGISTER_CONF_TEST_ADDRESS = "fire.config_center.register.conf.test.address" + // 配置中心接口header key + lazy val FIRE_CONFIG_CENTER_REGISTER_CONF_ZDP_HEADER_KEY = "fire.config_center.register.conf.zdp.header.key" + // 配置中心接口header value + lazy val FIRE_CONFIG_CENTER_REGISTER_CONF_ZDP_HEADER_VALUE = "fire.config_center.register.conf.zdp.header.value" // 配置打印黑名单,配置项以逗号分隔 lazy val FIRE_CONF_PRINT_BLACKLIST = "fire.conf.print.blacklist" // 是否启用动态配置功能 @@ -281,6 +285,10 @@ private[fire] object FireFrameworkConf { lazy val configCenterProdAddress = PropUtils.getString(this.FIRE_CONFIG_CENTER_REGISTER_CONF_PROD_ADDRESS, "") // 配置中心测试环境注册地址 lazy val configCenterTestAddress = PropUtils.getString(this.FIRE_CONFIG_CENTER_REGISTER_CONF_TEST_ADDRESS) + // 配置中心接口header key + lazy val configCenterZdpHeaderKey = PropUtils.getString(this.FIRE_CONFIG_CENTER_REGISTER_CONF_ZDP_HEADER_KEY, "") + // 配置中心接口header value + lazy val configCenterZdpHeaderValue = PropUtils.getString(this.FIRE_CONFIG_CENTER_REGISTER_CONF_ZDP_HEADER_VALUE, "") // 任务的唯一标识 lazy val configCenterAppId = PropUtils.getString(this.FIRE_CONFIG_CENTER_APP_ID) diff --git a/fire-common/src/main/scala/com/zto/fire/common/util/ConfigurationCenterManager.scala b/fire-common/src/main/scala/com/zto/fire/common/util/ConfigurationCenterManager.scala index fb7613e..47ced12 100644 --- a/fire-common/src/main/scala/com/zto/fire/common/util/ConfigurationCenterManager.scala +++ b/fire-common/src/main/scala/com/zto/fire/common/util/ConfigurationCenterManager.scala @@ -21,6 +21,7 @@ import com.zto.fire.common.bean.config.ConfigurationParam import com.zto.fire.common.conf.FireFrameworkConf import com.zto.fire.common.enu.ConfigureLevel import com.zto.fire.predef._ +import org.apache.commons.httpclient.Header import org.apache.commons.lang3.StringUtils /** @@ -43,7 +44,7 @@ private[fire] object ConfigurationCenterManager extends Serializable with Loggin val rest = FireFrameworkConf.fireRestUrl if (StringUtils.isBlank(rest)) logWarning("Fire Rest Server 地址为空,将无法完成注册") s""" - |{"className": "${className.replace("$", "")}", "url": "$rest", "fireVersion": "${FireFrameworkConf.fireVersion}", "zrcKey": "${FireFrameworkConf.configCenterSecret}", "engine": "${PropUtils.engine}", "appId": "${getFireAppId}"} + |{ "url": "$rest", "fireVersion": "${FireFrameworkConf.fireVersion}", "engine": "${PropUtils.engine}", "taskId": "${getFireAppId}"} """.stripMargin } @@ -75,7 +76,7 @@ private[fire] object ConfigurationCenterManager extends Serializable with Loggin */ private[this] def invoke(url: String, param: String): String = { try { - HttpClientUtils.doPost(url, param) + HttpClientUtils.doPost(url, param,new Header(FireFrameworkConf.configCenterZdpHeaderKey,FireFrameworkConf.configCenterZdpHeaderValue)) } catch { case _: Throwable => logError("调用配置中心接口失败,开始尝试调用测试环境配置中心接口。") "" -- Gitee