In an Event Driven Architecture when there are more than one microservices say A, B that publish same Event say Order_Created
and a service C listening to it, performs some actions and publishes an event say Credit_Reserved
for each new event on this type. My question is, while I can keep a CorrelationId
to track a chain of events for each instance of a microservice, should different services publish/consume same event types for such an operation or use their own types.
The scenario you described is what the Open Tracing standard is designed to resolve. The Open Tracing standard has several libraries and agregators that help to integrate it with your application. Basically, you set up a request context when you are calling out of your microservice. The agregators that visualize the complex interactions can show the layered calls unwinding to the parent context.
Combine that with open tracing in the client layer and you can trace the impact of a button click all the way through the system.
Credit_Reserved
in order to change the state of an order and say both A,B will have to check whether an order in say Pending state. Which is kind of unnecessary. – iamadnan Oct 11 '19 at 14:29credit_reserved
event proceed with next step. The other available options that I know of are to do a synchronous query to service C for credit-check. – iamadnan Oct 11 '19 at 14:47