飞书事件变更,mq更新
This commit is contained in:
@@ -8,7 +8,7 @@ import com.aliyun.openservices.ons.api.bean.Subscription;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.enums.RocketMqGroupEnum;
|
||||
import com.cool.store.mq.RocketMqConfig;
|
||||
import com.cool.store.mq.consumer.listener.UserEventDealListener;
|
||||
import com.cool.store.mq.consumer.listener.FeiShuEventListener;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -29,7 +29,7 @@ public class ConsumerClient {
|
||||
@Resource
|
||||
private RocketMqConfig rocketMqConfig;
|
||||
@Resource
|
||||
private UserEventDealListener userEventDealListener;
|
||||
private FeiShuEventListener feiShuEventListener;
|
||||
|
||||
/**
|
||||
* 获取通用配置
|
||||
@@ -66,17 +66,17 @@ public class ConsumerClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试test
|
||||
* 用户事件监听
|
||||
* @return
|
||||
*/
|
||||
@Bean(initMethod = "start", destroyMethod = "shutdown")
|
||||
public ConsumerBean test() {
|
||||
RocketMqGroupEnum groupEnum = RocketMqGroupEnum.DING_MSG_DEAL;
|
||||
RocketMqGroupEnum groupEnum = RocketMqGroupEnum.FEI_SHU_EVENT_LISTENER;
|
||||
ConsumerBean consumerBean = new ConsumerBean();
|
||||
//配置文件
|
||||
Properties properties = getCommonProperties(groupEnum);
|
||||
consumerBean.setProperties(properties);
|
||||
Map<Subscription, MessageListener> commonSubscriptionTable = getCommonSubscriptionTable(groupEnum, userEventDealListener);
|
||||
Map<Subscription, MessageListener> commonSubscriptionTable = getCommonSubscriptionTable(groupEnum, feiShuEventListener);
|
||||
//订阅多个topic如上面设置
|
||||
consumerBean.setSubscriptionTable(commonSubscriptionTable);
|
||||
return consumerBean;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.aliyun.openservices.ons.api.Message;
|
||||
import com.aliyun.openservices.ons.api.MessageListener;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dto.buser.UserEventDTO;
|
||||
import com.cool.store.enums.RocketMqTagEnum;
|
||||
import com.cool.store.service.EnterpriseSyncService;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -22,7 +23,7 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class UserEventDealListener implements MessageListener {
|
||||
public class FeiShuEventListener implements MessageListener {
|
||||
|
||||
@Autowired
|
||||
private RedisUtilPool redisUtilPool;
|
||||
@@ -37,13 +38,20 @@ public class UserEventDealListener implements MessageListener {
|
||||
return Action.CommitMessage;
|
||||
}
|
||||
log.info("重试消费次数 messageId:{},try times:{}", message.getMsgID(), message.getReconsumeTimes());
|
||||
|
||||
String lockKey = "DingMsgDealListener:" + message.getMsgID();
|
||||
boolean lock = redisUtilPool.setNxExpire(lockKey, message.getMsgID(), CommonConstants.NORMAL_LOCK_TIMES);
|
||||
if(lock){
|
||||
try {
|
||||
UserEventDTO reqBody = JSONObject.parseObject(text, UserEventDTO.class);
|
||||
enterpriseSyncService.userUpdateEvent(reqBody);
|
||||
RocketMqTagEnum tag = RocketMqTagEnum.getByTag(message.getTag());
|
||||
switch (tag){
|
||||
case USER_EVENT:
|
||||
UserEventDTO reqBody = JSONObject.parseObject(text, UserEventDTO.class);
|
||||
enterpriseSyncService.userUpdateEvent(reqBody);
|
||||
break;
|
||||
case AUTH_SCOPE_CHANGE:
|
||||
enterpriseSyncService.syncAll();
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
log.error("DingMsgDealListener consume dealAddressBookChange error",e);
|
||||
return Action.ReconsumeLater;
|
||||
@@ -196,6 +196,9 @@ public class EnterpriseSyncServiceImpl implements EnterpriseSyncService {
|
||||
break;
|
||||
case USER_DELETED:
|
||||
//人员职位删除状态,角色职位删除状态,人员从部门去除
|
||||
userRegionMappingDAO.deleteUserRegionByUserId(param.getUserId());
|
||||
enterpriseUserRoleDAO.deleteUserRole(param.getUserId());
|
||||
enterpriseUserDAO.deleteUserByUserId(param.getUserId());
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user