Split-join is a feature in Oracle Service Bus which allows to process messages in parallel. Split-Join is useful to reduce overall processing time as we process messages in parallel. As name suggest Split-Join split the request message to individual message and invoke business services in parallel, get the response from each business service and join that response.
There are two types if Split-Joins in Oracle Service Bus.
- Static Split-Join
- Dynamic Split-Join
In this post, we will discuss about Static Split-Join. In Static Split-Join, we have fixed number of parallel branches that we need to determine at design level only.
I will show one use case of Split-Join in this post which is based on below scenario.
Customer Portal need customer information from back end system to display it on the portal but all required information is not present in one system; it is present in two different systems. Customer Name information is stored in first system and Customer address information is stored in second system. So we need to get this information, join the information and send it to customer portal.
We use static split-join to design above scenario; in static split-join we add two branches which execute in parallel, one to get Customer name and other to get customer address.
Let’s start with this use case. We use eclipse to build static join as we can’t built it from OSB console.
First create an OSB project and add required folder structure to it.
Import below artifacts to OSB project.
- Customer Name service WSDL and XSD file: We use this to create business service which will be called from split join to get customer name.
- Customer Address service WSDL and XSD file: we use this to create business service which will be called from split-join to get customer address information.
- Customer Info Service WSDL and XSD file: we use this to create split join, this service define the request and response structure of message required by customer portal.
Repeat above step for Customer Address Business service.
Now we create split-join, right click on split join folder à New à Split-Join
Choose Customer Info service operation.
Now add “Parallel” Flow control activity to after receive activity in split-join.
Since we need to invoke only two services from this split-join so we need only two branches in parallel flow, now add invoke activity in each branch. Invoke activity used to call business service.
Configure invoke activity to invoke Customer Name business service.
Repeat above steps for Customer Address Services.
Once you configure the invoke activity to call business services then we need to create request and response variables for both customer name and address services.
Create these variables as local.
Once you complete the above step, your split join flow looks like below.
Now we need to initialize request variable, if you don’t initialize these variable then at run time you will get error.
To initialize and assign value to request message, add assign activity above invoke activity. From variable drop down select customer name service request message then click on “Expression”.
Add below text in the expression, this will initialize the request message and assign required input value to it.
Repeat above step for customer address request message variable assignment. Add below text for customer address request message in expression box.
After service invocation, we get the response from each service. Now we need to join the response from both the services to one final response.
Since we have created local variable for customer name and address services so we will not be access these variables outside parallel flow control. So to get the response of both the services, we create two global variables based on service response message.
After each invocation, we assign response from service to these global variables and then use these variables to join the response to final response.
To create global variable, go to top of the split-join, right click on variables and choose “Create variable”.
Create two global variables, one for each service response.
Now as mentioned above, we assign service response to above created global variables.
To do that, add assign activity after invoke activity, choose variable from variable drop down and click on expression.
Add below test to initialize the global variable and assign service response to it.
Customer Name Service
Customer Address Service
Now we need to assign each service response to final response. Since we can’t access service response variables outside parallel flow control so we use global variables to assign final response.
To do that add assign activity before reply activity, choose response variable from variable drop down and click on expression.
Add below text in expression box.
Your final split join should look like below.
We can’t use split join as it in proxy message flow, we need to generate business service from split-join and then we can use it.
To do that right click on split join and go to “Oracle Service Bus” and then click on “Generate Business Service”. This will generate business service for your split join.
Now deploy your project to OSB server and test the business service which we created from split-join.
Download sample code from here.