When a rabbitmq consumer gets a malformed message, completely empty, syntax error in json, undefined you name it. Consumer loops indefinitely by default without logging anything when requeue error handler is used (default) and setting up consumer programmatically.
the function in question that is needed to break
https://github.com/golevelup/nestjs/blob/master/packages/rabbitmq/src/amqp/connection.ts#L597
example code
import { AmqpConnection, defaultNackErrorHandler, } from '@golevelup/nestjs-rabbitmq';
...
await amqpConnection.createSubscriber<T>(
(payload) => {
if (!payload) {
throw new Error(`Received empty payload for ${event} event`);
}
return handler(payload);
},
{
exchange: 'someExchange',
routingKey: 'someRoutingKey',
queue: 'someQueue',
errorHandler: <can be overwritten here, log here and return nack >
},
The default errorHandler silently requeues the message, leading to an infinite loop.
I'm okay with the default of requeue, however i'd prefer to force the user to decide what behavior is wanted here since this is very much use case dependent.
And that in case of an error that error gets logged before a certain action is being done
What do you think about that?
When a rabbitmq consumer gets a malformed message, completely empty, syntax error in json,
undefinedyou name it. Consumer loops indefinitely by default without logging anything when requeue error handler is used (default) and setting up consumer programmatically.the function in question that is needed to break
https://github.com/golevelup/nestjs/blob/master/packages/rabbitmq/src/amqp/connection.ts#L597
example code
The default errorHandler silently requeues the message, leading to an infinite loop.
I'm okay with the default of requeue, however i'd prefer to force the user to decide what behavior is wanted here since this is very much use case dependent.
And that in case of an error that error gets logged before a certain action is being done
What do you think about that?