2

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.

6
  • its fine to have more than one service consume the same event. say order_complete sends an email to the customer and also removes an items from stock. Is this what you are asking? – Ewan Oct 11 '19 at 14:22
  • If both services A,B consume 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:29
  • That seems like a different problem. it's not inherent that they would have to do the same check, or that there aren't ways to avoid the duplication if they do – Ewan Oct 11 '19 at 14:32
  • In-fact it is this duplication/effort that tempted me to ask this question. I have this scenario where multiple services need to create order and based on credit_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
  • rewrite your question with the real names of the services and explain the duplication problem you are having. – Ewan Oct 11 '19 at 14:49
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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