2

I am having 2 micro service which are processing some inputted data (provided through queue ABC) asynchronously . after completing their processing they will push 2 messages into an another queue (queue ASD) that work has been done.

A subscriber is listening to the the queue ASD . On the basis of above 2 task completion , I want to run a function on subscriber when both of previous micro services completed their processing and pushed 2 related message to queue .

I am using RabbitMq as queue and nodejs as client.

Please suggest .

Pankaj Cheema
  • 1,028
  • 2
  • 13
  • 26

1 Answers1

0

If I understand your question correctly what you are trying to do is stream processing. Unfortunately, RabbbitMQ (based on AMQP) is a pure messaging tool and does not provide this. Kafka lets you do stream processing out of the box. You can also refer to this for more details on what I am saying.

There are a couple of not so efficient approaches to the problem though. You can just read all the messages from Queue 'ASD' and store them in db. Have another service/API read them periodically from this db. (or while writing to db this consumer can check if this is the second message and accordingly call the API). The final service can connect/associate them based on some attribute of the record, and do its work once both the records are available.

Ideally if it's not too late or you can, I would suggest using kafka instead of RabbitMQ for this use case.