Bi-Directional Sync Pattern
Bi-Directional Sync is a pattern where data flow from Source system to Target system and later from Target system to Source system. Idea is to make two system works together to achieve a business process or function.
Below example show a Customer portal which collects the Test Request which customer want to conduct on the Samples. Once customer portal has all the required information then it can sends the details to Lab system. Lab system take it’s time to conduct different test and later send the Test Results back to the Customer portal to share it with the customer. Here idea is to make these two application work together to provide the Lab Test functionality to Customers.
We can define Bi-Directional Sync in following steps
- Source system send a request to Target system
- Target system process the request
- Target system send the response back to Source system
MuleSoft API led approach in Bi-Directional Sync
Source system to Target system – As we understand we want to expose the functionality to target system to accept request from the Source system. We can create an experience API to expose interface to accept request which is Test Request in our case. Experience API will send the request to Process API for doing validation, transformation and enrichment before passing it to Target System API.
Advantage of having experience layer here, is in future if we like to accept the same request (Test Request) from other vendors or partners then we can use the same Experience API
Target system to Source system – In our case as Test results can be generated anytime then it should be of event type where Lab system will generate an event or notification to tell MuleSoft that Test Results are now available for specific Test request. Once MuleSoft have all the Test Result then it can pass the Customer Portal. If we have to send the Test results to other vendor or partner then their System API can be added without changing any other piece or with minimum change in existing APIs.
Thinking Laboratory exists within organization then we can create a Process API to either expose a one way interface (sync) or listen to JMS queue (async) to get the Test Results from the Laboratory.
If Laboratory is not a part of Organization then we can create an Experience API for the Laboratory to accept the Test Results
Reference blog – data-integration-patterns-bi-directional-sync