I am investigating employing a service bus architecture in our enterprise for coordinating data and business processes between systems in our environment.
Our situation is typical: customer-facing web applications that communicate messages to internal systems for billing, inventory, etc. We have several business entities that are common among most or all of these systems; each of these systems maintain their own versions of these entities in their own databases.
Applied to the service bus concept, we can publish a message to the bus from our customer web portal that represents an order. This message can be consumed by each interested system (billing, inventory, etc.) to create the corresponding customer records in their own databases. However, when one of these internal systems needs to publish a message about order status, it would carry the order ID from its own database. If our web portal needs to consume that message, it wouldn't know how to correlate the order ID sent to it from our internal system to the order ID that was saved to the web portal database.
Since no other system inherently is aware of how equivalent entities are correlated across systems, it seems that some type of mapping mechanism needs to be in place to allow systems to translate IDs contained in messages to the ID relevant to it. For example, a database table could be created that maps IDs from one system to another. This table could be queried to retrieve an appropriate ID for the target system. Our business currently does not utilize entity aggregation or some other '360-view' type repository to serve as a single authoritative source for common entity information from which a universal ID can be passed between and used by all systems.
Is using such an entity mapping approach to accompany a service bus implementation a valid approach? If so, are there any established guidelines to guide the design? If not, I am interested in hearing about alternative approaches to linking entities across systems to facilitate integration through a service bus.
PS: If it helps, I am currently evaluating the MassTransit framework for building our bus, so if there's info to offer specific to it, that is also very welcome.
Without more details I would consider an approach that looks similar to something like this...
- Website publishes a
- MiddleManager service would take that
SubmitNewOrdermessage and convert it into tasks for each system; with that conversion you could do ID translations
- Each system has an endpoint that would consume the right message/command and act accordingly
So some of the things here are that instead of sending your entities around you are sending commands. Now you could be sending subsets of your entities (which is a great time to extract an interface from your entities and compose message types). This would seem like a totally valid approach to this problem from a high level.
If you want to dig into this in some more depth, Enterprise Service Bus: Theory in Practice is an awesome book to get started with. It doesn't have anything to do with MassTransit, but many of the theories apply and set a great groundwork.