fix:修复数据同步配置校验缺失问题

(cherry picked from commit 13403ea027)
This commit is contained in:
hewencai
2025-12-16 18:43:08 +08:00
parent 218c6aa3dc
commit 7e25d6d106
2 changed files with 38 additions and 0 deletions

View File

@@ -15,6 +15,9 @@ import org.springframework.stereotype.Component;
* 用户-部门关系变更消息 Producer
* <p>
* 负责发送用户与部门的关联关系变更事件
* <p>
* 注意:客户端系统(分公司)应该禁用此功能,避免形成消息循环
* 配置项zt.databus.change.producer.enabled=false
*
* @author ZT
*/
@@ -25,6 +28,16 @@ public class DatabusUserDeptChangeProducer {
@Resource
private RocketMQTemplate rocketMQTemplate;
/**
* 是否启用变更消息发送
* <p>
* 默认值false安全优先避免未配置时导致消息循环
* 集团侧(数据源):必须显式设置为 true发送变更消息
* 分公司侧(客户端):保持 false 或不配置,禁用变更消息,避免循环
*/
@Value("${zt.databus.change.producer.enabled:false}")
private boolean enabled;
@Value("${zt.databus.change.topic-prefix:databus-change}")
private String topicPrefix;
@@ -98,6 +111,12 @@ public class DatabusUserDeptChangeProducer {
* 发送消息到 MQ
*/
private void sendMessage(DatabusEventType eventType, DatabusUserDeptData data) {
if (!enabled) {
log.debug("[Databus] 变更消息发送已禁用, 跳过用户-部门关系变更消息, eventType={}, userId={}, deptId={}",
eventType, data.getUserId(), data.getDeptId());
return;
}
DatabusMessage<DatabusUserDeptData> message = new DatabusMessage<>();
message.setEventType(eventType);
message.setData(data);

View File

@@ -15,6 +15,9 @@ import org.springframework.stereotype.Component;
* 用户-岗位关系变更消息 Producer
* <p>
* 负责发送用户与岗位的关联关系变更事件
* <p>
* 注意:客户端系统(分公司)应该禁用此功能,避免形成消息循环
* 配置项zt.databus.change.producer.enabled=false
*
* @author ZT
*/
@@ -25,6 +28,16 @@ public class DatabusUserPostChangeProducer {
@Resource
private RocketMQTemplate rocketMQTemplate;
/**
* 是否启用变更消息发送
* <p>
* 默认值false安全优先避免未配置时导致消息循环
* 集团侧(数据源):必须显式设置为 true发送变更消息
* 分公司侧(客户端):保持 false 或不配置,禁用变更消息,避免循环
*/
@Value("${zt.databus.change.producer.enabled:false}")
private boolean enabled;
@Value("${zt.databus.change.topic-prefix:databus-change}")
private String topicPrefix;
@@ -96,6 +109,12 @@ public class DatabusUserPostChangeProducer {
* 发送消息到 MQ
*/
private void sendMessage(DatabusEventType eventType, DatabusUserPostData data) {
if (!enabled) {
log.debug("[Databus] 变更消息发送已禁用, 跳过用户-岗位关系变更消息, eventType={}, userId={}, postId={}",
eventType, data.getUserId(), data.getPostId());
return;
}
DatabusMessage<DatabusUserPostData> message = new DatabusMessage<>();
message.setEventType(eventType);
message.setData(data);