fix:修复数据同步配置校验缺失问题
This commit is contained in:
@@ -15,6 +15,9 @@ import org.springframework.stereotype.Component;
|
|||||||
* 用户-部门关系变更消息 Producer
|
* 用户-部门关系变更消息 Producer
|
||||||
* <p>
|
* <p>
|
||||||
* 负责发送用户与部门的关联关系变更事件
|
* 负责发送用户与部门的关联关系变更事件
|
||||||
|
* <p>
|
||||||
|
* 注意:客户端系统(分公司)应该禁用此功能,避免形成消息循环
|
||||||
|
* 配置项:zt.databus.change.producer.enabled=false
|
||||||
*
|
*
|
||||||
* @author ZT
|
* @author ZT
|
||||||
*/
|
*/
|
||||||
@@ -25,6 +28,16 @@ public class DatabusUserDeptChangeProducer {
|
|||||||
@Resource
|
@Resource
|
||||||
private RocketMQTemplate rocketMQTemplate;
|
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}")
|
@Value("${zt.databus.change.topic-prefix:databus-change}")
|
||||||
private String topicPrefix;
|
private String topicPrefix;
|
||||||
|
|
||||||
@@ -98,6 +111,12 @@ public class DatabusUserDeptChangeProducer {
|
|||||||
* 发送消息到 MQ
|
* 发送消息到 MQ
|
||||||
*/
|
*/
|
||||||
private void sendMessage(DatabusEventType eventType, DatabusUserDeptData data) {
|
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<>();
|
DatabusMessage<DatabusUserDeptData> message = new DatabusMessage<>();
|
||||||
message.setEventType(eventType);
|
message.setEventType(eventType);
|
||||||
message.setData(data);
|
message.setData(data);
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import org.springframework.stereotype.Component;
|
|||||||
* 用户-岗位关系变更消息 Producer
|
* 用户-岗位关系变更消息 Producer
|
||||||
* <p>
|
* <p>
|
||||||
* 负责发送用户与岗位的关联关系变更事件
|
* 负责发送用户与岗位的关联关系变更事件
|
||||||
|
* <p>
|
||||||
|
* 注意:客户端系统(分公司)应该禁用此功能,避免形成消息循环
|
||||||
|
* 配置项:zt.databus.change.producer.enabled=false
|
||||||
*
|
*
|
||||||
* @author ZT
|
* @author ZT
|
||||||
*/
|
*/
|
||||||
@@ -25,6 +28,16 @@ public class DatabusUserPostChangeProducer {
|
|||||||
@Resource
|
@Resource
|
||||||
private RocketMQTemplate rocketMQTemplate;
|
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}")
|
@Value("${zt.databus.change.topic-prefix:databus-change}")
|
||||||
private String topicPrefix;
|
private String topicPrefix;
|
||||||
|
|
||||||
@@ -96,6 +109,12 @@ public class DatabusUserPostChangeProducer {
|
|||||||
* 发送消息到 MQ
|
* 发送消息到 MQ
|
||||||
*/
|
*/
|
||||||
private void sendMessage(DatabusEventType eventType, DatabusUserPostData data) {
|
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<>();
|
DatabusMessage<DatabusUserPostData> message = new DatabusMessage<>();
|
||||||
message.setEventType(eventType);
|
message.setEventType(eventType);
|
||||||
message.setData(data);
|
message.setData(data);
|
||||||
|
|||||||
Reference in New Issue
Block a user