Description
Is there an existing issue for this?
- I have searched the existing issues
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:
- prefetchCount: 1
- noAck: false
The mainly cause is the setting noAck
option has being false
.
When the application receives unhandle-able message, if noAck
is true
, the application will continue to receive message since unhandle-able message has been automatically acknowledged.
But noAck
is false
, 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 as 1
(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
- I don't know. Or some 3rd-party 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 (see below)
Other package
No response
NestJS version
9.0.0
Packages versions
{
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/microservices": "^9.4.1",
"@nestjs/platform-express": "^9.0.0",
"amqp-connection-manager": "^4.1.13",
"amqplib": "^0.10.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0"
}
Node.js version
18.15.0
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response