11 changed files with 138 additions and 49 deletions
@ -1 +1 @@ |
|||||
Subproject commit 235f56d5ea756317efe54c5e0d4be0ac45e09155 |
Subproject commit 9d7cf7e81ccc634751f032f72e5333a90eb40ee2 |
@ -0,0 +1,44 @@ |
|||||
|
package com.elink.esua.epdc.modules.rocketmq.consumer; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.RocketMqConstant; |
||||
|
import com.elink.esua.epdc.modules.group.service.UserGroupService; |
||||
|
import com.elink.esua.epdc.modules.rocketmq.dto.UserModifyDTO; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.rocketmq.common.message.MessageExt; |
||||
|
import org.apache.rocketmq.spring.annotation.MessageModel; |
||||
|
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
||||
|
import org.apache.rocketmq.spring.core.RocketMQListener; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 用户党员认证 |
||||
|
* |
||||
|
* @author zhy |
||||
|
* @date 2021/8/30 14:11 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
@RocketMQMessageListener(topic = RocketMqConstant.MQ_TOPIC_USER, consumerGroup = "${rocketmq.consumer.user.group}", messageModel = MessageModel.BROADCASTING) |
||||
|
public class UserModifyConsumer implements RocketMQListener<MessageExt> { |
||||
|
|
||||
|
@Autowired |
||||
|
private UserGroupService userGroupService; |
||||
|
|
||||
|
@Override |
||||
|
public void onMessage(MessageExt messageExt) { |
||||
|
log.info("EPDC-GROUP-SERVER消费消息START:{topic:{}, msgId:{}}", RocketMqConstant.MQ_TOPIC_USER, messageExt.getMsgId()); |
||||
|
try { |
||||
|
String charset = "UTF-8"; |
||||
|
String body = new String(messageExt.getBody(), charset); |
||||
|
UserModifyDTO dto = JSONObject.parseObject(body, UserModifyDTO.class); |
||||
|
// 用户党员认证
|
||||
|
userGroupService.modifyUserInfo(dto); |
||||
|
log.info("EPDC-GROUP-SERVER消费消息END:{topic:{}, msgId:{}, body:{}}", RocketMqConstant.MQ_TOPIC_USER, messageExt.getMsgId(), body); |
||||
|
} catch (Exception e) { |
||||
|
log.info("EPDC-GROUP-SERVER消费消息失败:msgId:{}", messageExt.getMsgId()); |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package com.elink.esua.epdc.modules.rocketmq.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 用户党员认证-接收MQ消息DTO |
||||
|
* 由于党员认证是单向的,所以不需要再记录新旧党员标识 |
||||
|
* |
||||
|
* @author zhy |
||||
|
* @date 2021/8/30 14:05 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class UserModifyDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -5692602006311937083L; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private String userId; |
||||
|
|
||||
|
} |
Loading…
Reference in new issue