I can't use two kafka client in one nest.js server to consume other topics. #13421
Closed
3 of 15 tasks
Labels
needs triage
This issue has not been looked into
Is there an existing issue for this?
Current behavior
hi, I have one problem about @nestjs/microservices package.
When I use two kafka consumer for one kafka brokers in one nest.js server, I want to use the kafka client consuming other topic in same broker.
but they consume every topic in same broker.
so, When nest.js consumes the topic for using
@MessagePattern(topic)
decorator, the two kafka clients consumes the topic's message at the same time. so event occurs twice at once.how can I make the kafka clients to consume other topics in one broker?
p.s.) Using same group id can be one of the solution, but I want to use different group id in two kafka client.
this is my example code
and then open the server and publish some message to "topic".
The console.log(message) occurs twice.
this is picture about what I want.
this is terminal screen shot
when I emit one message.
the consuming server consumes twice.
Is there any option about this?
Minimum reproduction code
No response (Please Refer to the above code)
Steps to reproduce
No response
Expected behavior
No response (Please Refer to the above code)
Related Issue
I think my problem is related to this issue.
So I suggest make
@MessagePattern
to use identifying id like@MessagePattern('topic', identifyingId)
and add identifyingId to microservice option.Or
how about to add the
topic
option toKafkaOptions
?like
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
10.0.0
Packages versions
Node.js version
20.11.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: