Search code examples
node.jsmoleculer

Moleculer pub/sub good practice


I protype with moleculer and just wondering on an architecural issue. My app is build with many pieces: moleculer services, redis, nats, C language app,... and it's deployed on ks8 cluster. I have to subscribe to an event published by moleculer service in my C app. Having redis and nats on board I have to options:

  • use native ioredis api from moleculer servise to publish an event and consume it in my C client (done)
  • use NATS moleculer tansporter and consume it in C client (not even started)

What is suggested way of dealing with such architecture from your point of view?


Solution

  • If measured by performance, then NATS will outperform REDIS on large data volumes.

    If it’s a matter of architecture design, then you won’t be able to take some moleculer events, you will need to fully implement the broker protocol and process events already. I do not think that this option is suitable for you. It is better to use a separate data bus, and in moelculer to make a service that will transmit internal events to the external data bus.