|
@@ -2,12 +2,12 @@ package org.jeecg.modules.mq;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
-
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-
|
|
|
import org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler;
|
|
|
import org.jeecg.boot.starter.rabbitmq.listenter.MqListener;
|
|
|
import org.jeecg.common.annotation.RabbitComponent;
|
|
|
+import org.jeecg.modules.adweb.common.util.AdwebRedisUtil;
|
|
|
import org.jeecg.modules.adweb.enquiry.dto.EnquiryDTO;
|
|
|
import org.jeecg.modules.adweb.enquiry.service.IAdwebEnquiryService;
|
|
|
import org.jeecg.modules.adweb.site.entity.AdwebSite;
|
|
@@ -18,8 +18,11 @@ import org.springframework.amqp.support.AmqpHeaders;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.messaging.handler.annotation.Header;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import static org.jeecg.modules.adweb.enquiry.service.impl.AdwebEnquiryServiceImpl.EnquiryUniqueKey;
|
|
|
+
|
|
|
/**
|
|
|
* Rabbit MQ - 询盘消息接收
|
|
|
*
|
|
@@ -29,9 +32,14 @@ import java.util.List;
|
|
|
@RabbitComponent(value = "enquiryReceiver")
|
|
|
public class EnquiryReceiver extends BaseRabbiMqHandler<EnquiryDTO> {
|
|
|
|
|
|
- @Autowired private IAdwebSiteService adwebSiteService;
|
|
|
+ @Autowired
|
|
|
+ private IAdwebSiteService adwebSiteService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAdwebEnquiryService adwebEnquiryService;
|
|
|
|
|
|
- @Autowired private IAdwebEnquiryService adwebEnquiryService;
|
|
|
+ @Resource
|
|
|
+ private AdwebRedisUtil adwebRedisUtil;
|
|
|
|
|
|
@RabbitHandler
|
|
|
// ackMode需要设置为MANUAL - BaseRabbiMqHandler.onMessage()有channel.basicAck()操作
|
|
@@ -50,6 +58,20 @@ public class EnquiryReceiver extends BaseRabbiMqHandler<EnquiryDTO> {
|
|
|
// 业务处理
|
|
|
log.info("收到MQ消息 {}", enquiry);
|
|
|
|
|
|
+ if (adwebRedisUtil.hasKey(EnquiryUniqueKey + enquiry.getSiteHost())) {
|
|
|
+ // 消息内容唯一性判断
|
|
|
+ List<String> enquiryUniqueIds = (List<String>) adwebRedisUtil.get(EnquiryUniqueKey + enquiry.getSiteHost());
|
|
|
+ // 如果该消息内容原数据中已存在,则将该重复消息踢出队列
|
|
|
+ if (enquiryUniqueIds.contains(enquiry.getSiteHost() + ">>>" + enquiry.getRecordId())) {
|
|
|
+ try {
|
|
|
+ channel.basicAck(deliveryTag, false);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 查看发布当前消息的站点是否是 adweb3 平台中绑定的是否是有效站点, 如果不是则直接确认消息,不做业务处理
|
|
|
List<AdwebSite> adwebSites =
|
|
|
adwebSiteService.list(
|