Explorar el Código

修改消息确认逻辑

tianboguang hace 2 años
padre
commit
de783b2ebc

+ 3 - 2
src/main/java/com/fdkankan/modeling/receiver/RabbitMqListener.java

@@ -24,6 +24,7 @@ import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
 import com.rabbitmq.client.Channel;
+import com.rabbitmq.client.Envelope;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.StopWatch;
@@ -97,7 +98,7 @@ public class RabbitMqListener {
             concurrency = "${maxThread.modeling.modeling-call}",
             priority = "${mq.consumerPriority}"
     )
-    public void buildSceneHandler(Channel channel, Message message, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) throws Exception {
+    public void buildSceneHandler(Channel channel, Envelope envelope, Message message, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) throws Exception {
         SysConstants.SYSTEM_BUILDING = true;
         if (SysConstants.SYSTEM_OFFING) {
             SysConstants.SYSTEM_BUILDING = false;
@@ -123,7 +124,7 @@ public class RabbitMqListener {
         this.process(buildSceneMessage);
         log.info("场景计算结束,队列名:{},id:{}", queueModelingCall, correlationId);
 
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+        channel.basicAck(envelope.getDeliveryTag(), false);
 
         //计算完毕,将当前系统构建状态改为false
         SysConstants.SYSTEM_BUILDING = false;