9 changed files with 429 additions and 8 deletions
@ -0,0 +1,62 @@ |
|||
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.GroupService; |
|||
import com.elink.esua.epdc.modules.police.service.PoliceService; |
|||
import com.elink.esua.epdc.modules.project.service.PropertyProjectService; |
|||
import com.elink.esua.epdc.modules.rocketmq.dto.OrganizationModifyDTO; |
|||
import com.elink.esua.epdc.modules.topic.service.TopicService; |
|||
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 1:54 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RocketMQMessageListener(topic = RocketMqConstant.MQ_TOPIC_ORGANIZATION, consumerGroup = "${rocketmq.consumer.group}", messageModel = MessageModel.BROADCASTING) |
|||
public class OrganizationModifyConsumer implements RocketMQListener<MessageExt> { |
|||
|
|||
@Autowired |
|||
private GroupService groupService; |
|||
|
|||
@Autowired |
|||
private TopicService topicService; |
|||
|
|||
@Autowired |
|||
private PropertyProjectService propertyProjectService; |
|||
|
|||
@Autowired |
|||
private PoliceService policeService; |
|||
|
|||
@Override |
|||
public void onMessage(MessageExt messageExt) { |
|||
log.info("EPDC-GROUP-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); |
|||
// 话题修改组织机构信息
|
|||
topicService.modifyOrganizationInfo(dto); |
|||
// 邻里党群修改组织机构信息
|
|||
groupService.modifyOrganizationInfo(dto); |
|||
// 物业项目修改组织机构信息
|
|||
propertyProjectService.modifyOrganizationInfo(dto); |
|||
// 民警修改组织机构信息
|
|||
policeService.modifyOrganizationInfo(dto); |
|||
log.info("EPDC-GROUP-SERVER消费消息END:{topic:{}, msgId:{}, body:{}}", RocketMqConstant.MQ_TOPIC_ORGANIZATION, messageExt.getMsgId(), body); |
|||
} catch (Exception e) { |
|||
log.info("EPDC-GROUP-SERVER消费消息失败:msgId:{}", messageExt.getMsgId()); |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue