0

Question about integrating bounded contexts. For example. I have organization AR in indentity BC. And courier service AR in logistics BC. They must be connected.

organization AR consists of:

  • OrganizationId
  • Name
  • TaxCode
  • LegalAddress
  • ...

courier service AR consists of:

  • CourierServiceId
  • Name
  • TransportationPriority
  • Rating
  • ...

Client send all these information in one request (Name, TaxCode, LegalAddress, TransportationPriority, Rating).

Questions:

  1. In which application should I submit a request to create two AR?
  2. How should i create both AR? After i created first AR in first BC, how should i create second AR from second BC?

The problem I faced:

At first I thought to publish domain event when organization AR created to notify logistics BC and create courier service AR. But when i publish domain event in first BC i must use language concepts as TransportationPriority, Rating(that needed to create AR in second BC). But this language concepts does not belong to first BC. However they are used in it. As i know it is wrong.

So how can I solve my problem? Sorry, my English is bad. Thanks so much.

Yury Golikov
  • 129
  • 1
  • 9

1 Answers1

1

Why "they must be connected"? From what I understand, you could have an OrgAR with multiple CourServAR. What it's possible to do, here, is the following:

  • the User lands in the page where he puts this information (you wrote that all the data comes together, so it should be done with a Form or something like this)
  • as soon he's there, I give him a couple of IDs (it's somewhere in a post of Udi Dahan, I don't find it now)
  • with this IDs, that you use for OrganizationId and CourierServiceId, you can send both the commands to the different domains without having to use events that share data that they don't know/have to use
    • of course it could be that storing one AR goes wrong, so you need a way to verify that the data integrity (with a job or something like this - then you've to notify the User that something went wrong during the process)

To get the IDs it could be that you have to write two services that give you the next useful ID for an OrgAR and an CourServAR.

Anyway, the fact the the two AR are bound together and you must store them together fires an alarm in my brain.

In fact, what I would do is:

  • identify what the User must really store (OrgAR or CourServAR? for example, I take OrgAR)
  • with this, create a Form to store OrgAR
  • then, give him the opportunity to store CourServAR
    • the second AR has already a link to the first (because I've its ID), what I need now is a command (in OrgBC) that says "assignCourServtoOrg" that just binds the two IDs in OrgAR
Luca Masera
  • 672
  • 7
  • 18
  • Thank you! Please tell me, does global ID from another bounded context violate the rules about ubiquitous language inside context? Have it must name which corresponds to ubiquitous language in local context? "assignCourServtoOrg" and "CourierServiceId" is strange thing for OrgAR. Isn't it? – Yury Golikov Feb 02 '18 at 19:25
  • I think no. How can you share "links" between BC entities if you don't use their IDs? If your domain requires this operation, model it without overlapping the BC. By the way, why do you need "assignCourServToOrg" snd CourierServiceId? What means the second? In my opinion you need just one service; after storing the second entity it acts (reacts, it's better) on the first one, that belongs to a different BC and binds it to the other. – Luca Masera Feb 03 '18 at 00:10