0

Let's suppose that I have two bounded contexts: A and B.

In books I'm reading authors will only write "Context A maps into Microservice A".

Now I'm working on a project (university assignment) in which I have one big context (A) that can (in my opinion) include a sub-context (B), as they both have the "same vision of the world".

When I started finding the related Microservices I have this architecture in which the big context (A) maps into two micro-services, one related to A itself, and one related to B.

Is this fine? or I'll just have to assume A and B as separate contexts?

2 Answers 2

2

I am not sure if nesting of bounded contexts is possible at all; I would say that if you're in such situation probably there're some modelling pitfalls in your design. Domain concepts should be relatively orthogonal between BCs, and what you're suggesting is a BC (nested) being a projection of a bigger one.

Onto your question, you can spread a given bounded context between multiple services given that the core model is shared between; this is called Shared Kernel in the DDD world. Depending on the concerns that lead you to such partitioning - you will probably have to partition based on application services or use cases. Heuristics here might be completely technical - eg: some service handling use cases heavily coupled with some storage technology or a given infrastructure adapter. -

0

Another approach for this is "Replicated datasets". In this case, each microservice contains exactly the data it needs. So,

  1. Use a message bus
  2. Raise events when things happen
  3. Listen for those events wherever they are interested in them
  4. Persist the data you need in each microservice
  5. Every microservice is completely independent now, so you can cut your bounded contexts down to exactly what you need (rather than needing to compose them of everything)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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