7

I have three (Node) processes P1, P2, P3.

  • Function A of P1 completes its execution it sends some data to P2.

  • P2 performs its activities and its output should be sent to P3.

  • P3 works on the input sends some acknowledgement data to Function B of P1.

All three are different Node applications and runs on different servers (in the same LAN). The question is what should be the communication mechanism between these processes.

Three options appear to be viable:

1) REST API (Express)

Let all the processes be Express REST APIs and using the http Node package call the required functions

2) Pub/Sub

When P1 completes the work, it post the output as a message to a topic and P2 becomes a subscriber and onMessage P2 process executes.

3) TCP/IP

A simple TCP/IP server-client architecture where P1 becomes the server client and P2 as server. Whenever P1 completes the work send the output through sockets.

All three options are for used for many to one or many to many communication so I guess there could be a lot of unnecessary overhead as my requirement has only one to one communication between the processes.

Is there any other method that I can use that best suits the dilemma?

1 Answer 1

6

You can work with mqtt protocol. This is a very light weight and fast protocol. In this protocol you will get a publisher, a subscriber and a broker. Publisher will send data to subscriber under a topic via mqtt broker. It is almost same as Pub/Sub.

MQTT Architecture

MQTT

Note : Function A of P1 will publish data and P2 will subscribe. After P2 completes its activities it will publish data to P3 and P3 will be in subscribing mode. After that P3 will publish acknowledgement and Function B of P1 will subscribe the topic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.