Search code examples
node.jsrabbitmqmicroservices

node/rabbitmq : choreography asynchronous and reponse


Hello I have a question about choreography,

I know it's asynchronous, but in this context:

a requisition in endPoint / addEmployee (where to create an employee the existence in the department is necessary), I would check for an employee and send a message in my department queue to verify the existence and also sign up in the queue to hear the answer, would that be choreography?

Or when confirming the existence of the employee, should I create and send the response already? or can i send the response after consuming the departament queue?

Or in this case, would the orchestration be correct?


Solution

  • If I understand correctly you are receiving a request or a message which contains information to create an employee. One of those field is department name or id. And you would like to validate existence of this department information from department service. Is my understanding correct? If so I would say a lot easier solution would be keeping a basic department data on your employee service. You can get department created, updated events from department service and sync your data instead of asking for each and every employee.

    With this solution you wont have a dependency between services. You will just listen the topic or queue to which you wont know where the message comes from which is total opposite of the coupling.