Nest application with RMQ connection may freeze depending on configuration #11641
Closed
3 of 15 tasks
Labels
needs triage
This issue has not been looked into
Is there an existing issue for this?
Current behavior
In the following case, a nest application with the RabbitMQ microservice integration will freeze when the application has received a message which has a pattern that is not registered within the controller.
RabbitMQ Options:
The mainly cause is the setting
noAck
option has beingfalse
.When the application receives unhandle-able message, if
noAck
istrue
, the application will continue to receive message since unhandle-able message has been automatically acknowledged.But
noAck
isfalse
, the application will keep waiting for unhandle-able message is acknowledged, and this message will consume prefetchCount. Finally if prefetchCount is filled by unhhandle-able messages, the application can't fetch new message, it seems to be freezed.Background
I tried to build an application to process important heavy job using RabbitMQ with above options.
This application has to change acknowledgement strategy for each job result. For example, if the job has succeeded it should be acknowledged, if the job has failed due to the retry-able cause it should be nack-ed with true retry flag.
So the noAck option should be set as
false
, then the prefetchCount option should be set as1
(or enough small value) by mentioned reason.Minimum reproduction code
https://github.com/ryoctrl/nest-rmq-unack
Steps to reproduce
No response
Expected behavior
When a nest application receives an unknown pattern's message, I want the application to dispose the message then it should handle next message.
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
9.0.0
Packages versions
Node.js version
18.15.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: