From a561068a61bd142318913f2e12e58d44542d9c7e Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期二, 06 五月 2025 14:30:19 +0800 Subject: [PATCH] Merge branch 'dev' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile into dev --- ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/PlatformStartChargingReplyMessageListener.java | 63 ++++++------------------------- 1 files changed, 12 insertions(+), 51 deletions(-) diff --git a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/PlatformStartChargingReplyMessageListener.java b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/PlatformStartChargingReplyMessageListener.java index a22254f..decb747 100644 --- a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/PlatformStartChargingReplyMessageListener.java +++ b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/PlatformStartChargingReplyMessageListener.java @@ -23,10 +23,9 @@ messageModel = MessageModel.CLUSTERING, consumerGroup = "charge_platform_start_charging_reply", topic = "charge_platform_start_charging_reply", - selectorExpression = "platform_start_charging_reply", - consumeThreadMax = 5 //默认是64个线程并发消息,配置 consumeThreadMax 参数指定并发消费线程数,避免太大导致资源不够 + selectorExpression = "platform_start_charging_reply" ) -public class PlatformStartChargingReplyMessageListener extends EnhanceMessageHandler<PlatformStartChargingReplyMessage> implements RocketMQListener<PlatformStartChargingReplyMessage> { +public class PlatformStartChargingReplyMessageListener implements RocketMQListener<PlatformStartChargingReplyMessage> { @Autowired private PlatformStartChargingReplyService platformStartChargingReplyService; @@ -36,58 +35,20 @@ - @Override - protected void handleMessage(PlatformStartChargingReplyMessage message) throws Exception { - // 此时这里才是最终的业务处理,代码只需要处理资源类关闭异常,其他的可以交给父类重试 - log.info("远程启机命令回复-业务消息处理:{}",message); - // 持久化消息 - PlatformStartChargingReply platformStartChargingReply = new PlatformStartChargingReply(); - BeanUtils.copyProperties(message,platformStartChargingReply); - platformStartChargingReplyService.create(platformStartChargingReply); - // 业务处理 - PlatformStartChargingReplyMessageVO message1 = new PlatformStartChargingReplyMessageVO(); - BeanUtils.copyProperties(message, message1); - chargingOrderClient.startChargeSuccessfully(message1); - } - - @Override - protected void handleMaxRetriesExceeded(PlatformStartChargingReplyMessage message) { - // 当超过指定重试次数消息时此处方法会被调用 - // 生产中可以进行回退或其他业务操作 - log.error("消息消费失败,请执行后续处理"); - } - - - /** - * 是否执行重试机制 - */ - @Override - protected boolean isRetry() { - return true; - } - - @Override - protected boolean throwException() { - // 是否抛出异常,false搭配retry自行处理异常 - return false; - } - - /** - * 若需要处理消息过滤,在父级中进行统一处理,或者在此处实现之后,自行处理 - * @param message 待处理消息 - * @return true: 本次消息被过滤,false:不过滤 - */ - @Override - protected boolean filter(PlatformStartChargingReplyMessage message) { - // 此处可做消息过滤 - return false; - } - /** * 监听消费消息,不需要执行业务处理,委派给父类做基础操作,父类做完基础操作后会调用子类的实际处理类型 */ @Override public void onMessage(PlatformStartChargingReplyMessage message) { - super.dispatchMessage(message); + log.info("远程启机命令回复-业务消息处理:{}",message); + // 持久化消息 + PlatformStartChargingReply platformStartChargingReply = new PlatformStartChargingReply(); + BeanUtils.copyProperties(message,platformStartChargingReply); + platformStartChargingReplyService.create(platformStartChargingReply); + + // 业务处理 + PlatformStartChargingReplyMessageVO message1 = new PlatformStartChargingReplyMessageVO(); + BeanUtils.copyProperties(message, message1); + chargingOrderClient.startChargeSuccessfully(message1); } } \ No newline at end of file -- Gitblit v1.7.1