Small docker-compose demo of a Moleculer.js Publish/Subscribe infrastructure using NATS.
This project should show an issue in Moleculer.js. You can find the related ticket here.
-
Check out the repository
-
Run
docker-compose up -build
You will now see that
moleculer-publisher
sends events to the NATS server. Both subscribers (moleculer-subscriber
andnodejs-subscriber
) will receive these events and log them. As thenodejs-subscriber
subscribes to a wildcard it will also log all heartbeats from themoleculer-publisher
. -
Go to
docker-compose.yml
and comment out themoleculer-subscriber
. -
Run
docker-compose up -build
You will now see that the
nodejs-subscriber
does still receive the heartbeat events from themoleculer-publisher
but not the test event.
Moleculer will only publish events to the transporter (NATS in this case) if another Moleculer service is registered in the Service Registry of Moleculer. If not no events will be broadcasted (only heartbeats). If you use Moleculer together with other frameworks they will not receive any events unless one of them is a Moleculer service.
It would be great to have an option that forces Moleculer to send events to the transporter no matter if another service is registered in the Service Registry or not. This is crucial to be able to use Moleculer in an diverse micro service environment.