Data sharing between nodejs micro services using events

Viewed 528

So I am having a micro service architecture for my project, were I have like 2-3 services running. I need to call in an action based on some events that triggered on these services.

How can I achieve that, using nodejs event emitter class, or any other similar services. Is socket.io an alternative?

Or is it even possible?

1 Answers

The relevant events (that you need for communication betwenn your distributed services) need to be part of the "public" api of your microservice. So the service that throws (domain) events can either offer same pub/sub mechanism or you use a message oriented middleware (RabbitMQ, Kafka,...) In your microservice you can have an interface service that subscribes to the internal triggered events and then retrigger the relevant ones to this public api..

Related