AMQPLib and RabbitMQ

Channel closed by server: 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED

As explained by this article this implies that your channel has consumed a message without ACKing or NACKing it and it has timed out. Make sure to ACK or NACK all messages when you receive them - typically after processing just in case something goes wrong there.

this.channel?.consume(q?.queue, (msg: amqplib.ConsumeMessage | null) => {

            if(!msg){
                throw new Error(`Received a null message - weirdness.`)
            }

            try{

                const result = callback(msg)

                this.channel?.ack(msg)

                return result

            }catch(err) {
                console.log(err)
                this.channel?.nack(msg)
            }
})

Revision #2
Created 2022-10-19 09:36:37 UTC by James
Updated 2024-01-21 14:54:02 UTC by James