nestjs icon indicating copy to clipboard operation
nestjs copied to clipboard

RabbitMQ: Connection Resiliency functions in unexpected manner

Open ssilve1989 opened this issue 5 years ago • 2 comments

Current Functionality

Currently it looks like the only way connection resiliency is supported is through setting wait: false on the connectionInitOptions. This results in the Nest service reporting that it has been successfully bootstrapped even though a Rabbit connection may have not been established. This results in application lifecycle events, like, onApplicationBootstrap being triggered before a rabbit connection could be established placing the burden of verifying the connection onto a consumer (some module injecting AmqpConnection)

Expected Functionality

Instead, I would expect additional functionality to be available, similar to that of the @nestjs/typeorm module where the module does not report it is ready until a connection is successfully established. The current property wait when set to true is misleading, in that it does not wait for a connection, instead it just fails if a connection cannot be established within the timeout period

[ERROR] 39404 - 11/16/2020, 7:51:41 AM [Nest] Failed to connect to a RabbitMQ broker within a timeout of 30000ms
Error: Failed to connect to a RabbitMQ broker within a timeout of 30000ms

resulting in the application crashing. There should be additional properties, as requested here #200 that alongside the wait:true property allow for attempting to connect up to N times with some delay before throwing an error.

ssilve1989 avatar Nov 16 '20 14:11 ssilve1989

same issue here!!

dimauloagustin avatar Dec 01 '23 13:12 dimauloagustin