Search code examples
microservicesnestjs

NestJs Micro service event based architecture


My problem is the following. Considering a micro service architecture with nestJs, some action are triggered by event.

Assume I have "user service" that throw "user.created" event when ne user is registered on DB, some others services can listen this event. If a service scale, mean there are more than & instance a a service running in same time, the message is consumed many time by the same "kind of service".

How can I resolve this problem ?

Her you'll find a complete example project with above use case and running code : https://github.com/quentin-bardenet/nest-u-service-scalability-problem


Solution

  • Finally it's ok, I replace Redis transporter by NATS. NATS support queue then I can create kind of groups.

    I updated the previous repository with the working code, maybe it could help someone.