zhangliang hace 6 horas
padre
commit
ed7c06b129
Se han modificado 1 ficheros con 6 adiciones y 3 borrados
  1. 6 3
      scheduler/async_consumer.py

+ 6 - 3
scheduler/async_consumer.py

@@ -34,6 +34,10 @@ async def async_handle_topic(topic: str, stop_event: asyncio.Event):
                 task_id = payload["id"]
 
                 logger.info(f"[{topic}]接收到任务消息: {task_id}")
+                # 确认消息(单条消息处理成功后才 Ack)
+                await consumer.ack_message(message.receipt_handle)
+                logger.info(f"[{topic}]任务 {task_id} 已 Ack")
+
                 aliyun_logger.logging(
                     code="1000",
                     message="任务接收成功",
@@ -54,10 +58,9 @@ async def async_handle_topic(topic: str, stop_event: asyncio.Event):
                 )
                 await crawler.run()  # 爬虫成功执行后再确认消息
 
-                # 确认消息(单条消息处理成功后才 Ack)
-                await consumer.ack_message(message.receipt_handle)
 
-                logger.info(f"[{topic}]任务 {task_id} 执行成功并已 Ack")
+
+                logger.info(f"[{topic}]任务 {task_id} 执行成功")
                 aliyun_logger.logging(
                     code="1010",
                     message="任务执行成功",