BizTalk orchestrations can be designed to run discrete pieces of work, following the classic ‘ACID’ concept of a transaction. If we need to debatch a Message inside a Biztalk orchestration, we will need to use an atomic scope in order to ensure the reliable transaction. However, the drawback of this approach is that each process called in this scope needs to respect this transaction atomicity. So, if we need to add an information into the original message the only way is to use self-correlating port. To illustrate our case, we will use the SWAPI API (https://swapi.co/api/people) which regroup Star Wars characters, planets and movies. It allows us to get the list of characters with some information like name, age or url of their home planet. Our goal will be to obtain the list of characters with the name of their home planet and save these data in a folder. To do this, we need two orchestrations: the main orchestration in charge of getting the list of characters and the child orchestration in charge of getting the planet name for each character.
Getting Star Wars characters wihin BizTalk Orchestration
The first step is to obtain the characters list from the API. Port configuration is made with an expression shape
Debatching message and calling the child orchestration
For each Star Wars character we got, we have to find their home planet. Hence we need to debatch the data got from our first API call.
In our orchestration, debatching process is done inside an atomic scope using the XMLReceive debatching pipeline. Then we looping through each characters using BizTalk orchestration looping feature. Inside the loop, the orchestration constructs a single message for each movie character. Then, each message is sent to the child orchestration to obtain the name of its planet. While we are in the atomic scope, the child orchestration could be launched only in start mode.
The child orchestration and self-correlating port
Self-correlating port is the essential part of the child orchestration. The first step is to create a port type which sends back the movie character information with the home planet. In the orchestration, the logical port associated to this port type has to be configured with a direct binding and the self-correlating option checked.
This self-correlating port needs to be referenced as a child orchestration parameter and used in the main orchestration on the Start Orchestration shape.
So the child orchestration looks like this.
Final message construction
In the main orchestration, The self-correlating port will recover each single message coming from the child orchestration. A loop reaggregates all the messages into one and then the final list is sent to the file folder
Main orchestration overview