DEV Community

Cover image for Kafka Microservice using Nest Js

Kafka Microservice using Nest Js

Kannan on September 19, 2020

Hello All, Hope you are doing well. In this article, we are going to learn about how to set up a microservice using NestJs and Kafka. Why did I ...
Collapse
 
igortas profile image
Igor Tashevski •

This is weird example. Why the producer service, has @client decorator?

Collapse
 
kannndev profile image
Kannan •

I am not sure why do you call this weird. Producer is the service which generates the message so that is why it has a client decorator.

Collapse
 
igortas profile image
Igor Tashevski •

I was more thinking, if is possible to annotate the services in a way, what is what, server-service, client-service. There is ServerKafka class, but I can't find way how to use it. There is nothing like @client decorator, to be replaced, like @server.

Thread Thread
 
kannndev profile image
Kannan •

Why would you need a decorator for Server. Here the consumer is a microservice server listening on kafka queues. A single service class cannot become a server isnt it?

Thread Thread
 
igortas profile image
Igor Tashevski •

When it's appropriate to use ServerKafka class?

Thread Thread
 
kannndev profile image
Kannan •

Can you point me to the documentation where you found this.

Collapse
 
abomb302 profile image
abomb302 •

Thank you! not found any repo demo full communication from producer to consumer until this.

Collapse
 
theringleman profile image
Sam Ringleman •

Excellent write up, quick concise and to the point! Thanks for taking the time!

Collapse
 
____jackson___ profile image
jackson •

感谢你的分享帮助到我!! Thank you for sharing and helping me.

Collapse
 
thiagonovato profile image
Thiago Novato •

I'd like only produce a message. In this case, need i use some decorator (EventPattern or MessagePattern) to consume a message of a topic? Because in your example, whitouth a subscriber, do not work.

Collapse
 
lmdinez profile image
lmdinez •

how do i create kafka topic partition when send data to kafka topic

Collapse
 
rais_joel profile image
joel beyantumba •

Wonderful, you give me the first tuto that worked finally! Thanks a lot