8 changed files with 173 additions and 4 deletions
@ -0,0 +1,46 @@ |
|||||
|
package com.elink.esua.epdc.mq; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.RocketMqConstant; |
||||
|
import com.elink.esua.epdc.mq.dto.OrganizationModifyDTO; |
||||
|
import com.elink.esua.epdc.service.PointsLogsService; |
||||
|
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; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 组织机构信息修改-监听MQ消息 |
||||
|
* |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2020/3/7 13:47 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
@RocketMQMessageListener(topic = RocketMqConstant.MQ_TOPIC_ORGANIZATION, consumerGroup = "${rocketmq.consumer.group}", messageModel = MessageModel.BROADCASTING) |
||||
|
public class OrganizationModifyConsumer implements RocketMQListener<MessageExt> { |
||||
|
|
||||
|
@Autowired |
||||
|
private PointsLogsService pointsLogsService; |
||||
|
|
||||
|
@Override |
||||
|
public void onMessage(MessageExt messageExt) { |
||||
|
log.info("EPDC-POINTS-SERVER消费消息START:{topic:{}, msgId:{}}", RocketMqConstant.MQ_TOPIC_ORGANIZATION, messageExt.getMsgId()); |
||||
|
try { |
||||
|
String charset = "UTF-8"; |
||||
|
String body = new String(messageExt.getBody(), charset); |
||||
|
OrganizationModifyDTO dto = JSONObject.parseObject(body, OrganizationModifyDTO.class); |
||||
|
//积分日志表修改组织机构信息
|
||||
|
pointsLogsService.modifyOrganizationInfo(dto); |
||||
|
|
||||
|
log.info("EPDC-POINTS-SERVER消费消息END:{topic:{}, msgId:{}, body:{}}", RocketMqConstant.MQ_TOPIC_ORGANIZATION, messageExt.getMsgId(), body); |
||||
|
} catch (Exception e) { |
||||
|
log.info("EPDC-POINTS-SERVER消费消息失败:msgId:{}", messageExt.getMsgId()); |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
package com.elink.esua.epdc.mq.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 组织机构信息修改-接收MQ消息DTO |
||||
|
* |
||||
|
* @Author:liuchuang |
||||
|
* @Date:2020/3/7 13:46 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class OrganizationModifyDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -5692602006311937083L; |
||||
|
|
||||
|
/** |
||||
|
* 部门ID |
||||
|
*/ |
||||
|
private Long deptId; |
||||
|
|
||||
|
/** |
||||
|
* 旧部门名称 |
||||
|
*/ |
||||
|
private String oldDeptName; |
||||
|
|
||||
|
/** |
||||
|
* 新部门名称 |
||||
|
*/ |
||||
|
private String newDeptName; |
||||
|
|
||||
|
/** |
||||
|
* 部门类型 |
||||
|
*/ |
||||
|
private String typeKey; |
||||
|
} |
Loading…
Reference in new issue