Skip to content

Commit

Permalink
fix: only ack message if noAck option is false
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Jun 12, 2024
1 parent fe2fd54 commit d6102e3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,22 @@ export class Client {
handlers[ConsumeHandlerAnyKey];

if (typeof handler === 'undefined') {
ch.nack(message, undefined, requeueOnFailure);
if (!options.noAck) {
ch.nack(message, undefined, requeueOnFailure);
}
return;
}

try {
await handler(message, ch);

ch.ack(message);
if (!options.noAck) {
ch.ack(message);
}
} catch (e) {
ch.nack(message, undefined, requeueOnFailure);
if (!options.noAck) {
ch.nack(message, undefined, requeueOnFailure);
}
}
};

Expand Down

0 comments on commit d6102e3

Please sign in to comment.