企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
[TOC] ### 消息应答 ack >[danger] noAck: false 手动接收消息模式 ``` async consume() { const ch = await this.app.amqplib.createChannel(); await ch.assertQueue(queueName, { durable: false }); const msg = await new Promise(resolve => ch.consume(queueName, msg => resolve(msg) , { noAck: false } )); if (msg !== null) { // 告诉MQ 我已经收到消息并处理完成了,MQ会删除队列中的消息,并从内存中删除 ch.ack(msg); await ch.close(); this.ctx.status = 200; this.ctx.body = { msg: msg.content.toString() }; } else { this.ctx.status = 500; } } ``` ***** ### 消息持久化