How do you use the producer and consumer to expose as an API using node express?
kprytsm opened this issue · 2 comments
kprytsm commented
I am new to Kafka and recently I want to develop a producer and consumer API using node express framework.
While developing I encounter 2 issues:
- After I consume once with the consumer.js file, I cannot get any response if I try to call the consumer api again
producer.txt
consumer.txt
app.txt
- What is the best way to control the consumer group (for this part I haven't implemented into the code yet). For example, if my topic has two partition, and I want two different API session to consume each of the partition, how should I set the consumer option properly in the Kafka-node consumer?
Appreciate if you can help me on these issues, sorry if it is being too simple.
kprytsm commented
I am suspecting "process.exit()" cause me the issue mentioned in point 1.....
I am using nodemon to run app.js btw.
kprytsm commented
after some trial and error, I use pm2 to host the app.js and I can now call the consumer api again and again, but anyone can explain why?