0

I recently faced a problem when I designed the microservices architecture of our new system. To give more context on that, let's suppose that we have two different services.

  • A service is responsible to make payments and the other one

  • B service is responsible to keep track of the orders.

We have a use case that we need to update an order state from the service A.

We have these states in an enumeration list inside the service B.

How can I avoid the sharing of this enumeration between two services? I need to have decoupled services.

Please feel free to ask for clarifications.

pik4
  • 1,283
  • 3
  • 21
  • 56

2 Answers2

1

Not sure whether i got your question correct. Lets say there are three cases in your payment service eg: success, failed, pending, and there are specific states defined in order service. And we don't want to share anything between these two microservices in terms of data states. Would suggest you to publish event to queue for any given payment state. And make order service to listen this event, and have conditional logic to update order status here. This way we can achieve loosely coupled services.

Bhagwati Malav
  • 3,349
  • 2
  • 20
  • 33
0

What you are describing sounds like Service A is dependent on Service B and there has to be a necessary service interface. If the states are information that the service provides they should be seen as part of the API and thus made available for consumers as part of the API description.

Also a general note - I assume the reason you are asking the question is insecurity about the exact service boundaries. Note that drawing the right service boundaries is the hardest part of designing any system in the microservices architectural style. The boundaries should typically be domain specific, but potentially also need to consider organizational and technical constraints. See this article and I recommend reading all of Fowler's materials about the subject.

Oswin Noetzelmann
  • 9,166
  • 1
  • 33
  • 46