Skip to content

Commit 537917a

Browse files
committed
fix(amqp): added error handling when subscription fails to not crash the whole server
1 parent 35aeed9 commit 537917a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/amqp/src/decorators/subscribe.decorator.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ export const Subscribe =
2020
const amqpService = set(AmqpService);
2121
await amqpService.subscribe(
2222
queue,
23-
(msg, channel) => target[memberName].call(this, msg, channel),
23+
async (msg, channel) => {
24+
try {
25+
await target[memberName].call(this, msg, channel);
26+
} catch (e) {
27+
console.error(
28+
`[Subscription]: queue "${queue}" fail internally inside ${target} ${memberName}`
29+
);
30+
}
31+
},
2432
{ assertOptions, consumeOptions }
2533
);
2634
return OnInit.apply(this, args);

0 commit comments

Comments
 (0)