From 12bf4a0109e43d2a44fca67568f1f636b6461897 Mon Sep 17 00:00:00 2001 From: waynaqua <1669738430@qq.com> Date: Mon, 15 Jan 2024 10:40:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(mall):=20=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/wayn/message/consumer/OrderDelayConsumer.java | 4 ++-- .../main/java/com/wayn/message/consumer/OrderPayConsumer.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/waynboot-message-consumer/src/main/java/com/wayn/message/consumer/OrderDelayConsumer.java b/waynboot-message-consumer/src/main/java/com/wayn/message/consumer/OrderDelayConsumer.java index 6785a36..424be16 100644 --- a/waynboot-message-consumer/src/main/java/com/wayn/message/consumer/OrderDelayConsumer.java +++ b/waynboot-message-consumer/src/main/java/com/wayn/message/consumer/OrderDelayConsumer.java @@ -31,7 +31,7 @@ public class OrderDelayConsumer { String msgId = message.getMessageProperties().getHeader("spring_returned_message_correlation"); long deliveryTag = message.getMessageProperties().getDeliveryTag(); // 消费者消费消息时幂等性处理 - if (redisCache.getCacheMap(UNPAID_ORDER_CONSUMER_MAP.getKey()).containsKey(msgId)) { + if (redisCache.getCacheObject(UNPAID_ORDER_CONSUMER_MAP.getKey(msgId)) != null) { // redis中包含该 key,说明该消息已经被消费过 log.error("msgId: {},消息已经被消费", msgId); channel.basicAck(deliveryTag, false);// 确认消息已消费 @@ -41,7 +41,7 @@ public class OrderDelayConsumer { mobileApi.unpaidOrder(body); // multiple参数:确认收到消息,false只确认当前consumer一个消息收到,true确认所有consumer获得的消息 channel.basicAck(deliveryTag, false); - redisCache.setCacheObject(UNPAID_ORDER_CONSUMER_MAP.getKey(), msgId, ORDER_CONSUMER_MAP.getExpireSecond()); + redisCache.setCacheObject(UNPAID_ORDER_CONSUMER_MAP.getKey(msgId), msgId, ORDER_CONSUMER_MAP.getExpireSecond()); } catch (Exception e) { channel.basicNack(deliveryTag, false, false); log.error(e.getMessage(), e); diff --git a/waynboot-message-consumer/src/main/java/com/wayn/message/consumer/OrderPayConsumer.java b/waynboot-message-consumer/src/main/java/com/wayn/message/consumer/OrderPayConsumer.java index adef397..cf64c3c 100644 --- a/waynboot-message-consumer/src/main/java/com/wayn/message/consumer/OrderPayConsumer.java +++ b/waynboot-message-consumer/src/main/java/com/wayn/message/consumer/OrderPayConsumer.java @@ -31,7 +31,7 @@ public class OrderPayConsumer { String msgId = message.getMessageProperties().getHeader("spring_returned_message_correlation"); long deliveryTag = message.getMessageProperties().getDeliveryTag(); // 消费者消费消息时幂等性处理 - if (redisCache.getCacheObject(ORDER_CONSUMER_MAP.getKey()) != null) { + if (redisCache.getCacheObject(ORDER_CONSUMER_MAP.getKey(msgId)) != null) { // redis中包含该 key,说明该消息已经被消费过 log.error("msgId: {},消息已经被消费", msgId); channel.basicAck(deliveryTag, false);// 确认消息已消费 @@ -41,7 +41,7 @@ public class OrderPayConsumer { mobileApi.submitOrder(body); // multiple参数:确认收到消息,false只确认当前consumer一个消息收到,true确认所有consumer获得的消息 channel.basicAck(deliveryTag, false); - redisCache.setCacheObject(ORDER_CONSUMER_MAP.getKey(), msgId, ORDER_CONSUMER_MAP.getExpireSecond()); + redisCache.setCacheObject(ORDER_CONSUMER_MAP.getKey(msgId), msgId, ORDER_CONSUMER_MAP.getExpireSecond()); } catch (Exception e) { channel.basicNack(deliveryTag, false, false); log.error(e.getMessage(), e);