Advertisements



Service Bus 12c–Creating Static Split-Join

In this post, you will learn to create and use Split Join and will use the same XYZCustomer project used in previous posts.

Split Join allows you to split the request payload so that you can call multiple services concurrently as opposed to the sequential processing. This way, you will achieve improved service performance.

In this post, you use Split Join to aggregate Customer Information by invoking different business services in parallel. The Customer Information includes basic Customer Details, Orders and Accounts. You can create the business services using the WSDLs given below. Make sure that you create 3 business services named CustomerServiceBS, CustomerOrderServiceBS and CustomerAccountServiceBS using following WSDLs respectively.

Purpose

Service WSDL

Customer Object operations

CustomerService.wsdl

Customer Order operations

CustomerOrderService.wsdl

Customer Account operations

CustomerAccountService.wsdl

Split Join can only be created based on WSDL so create new WSDL in WSDLs folder, having single operation with following. You can get the WSDL used in this post from .

  • Customer ID as input.
  • Customer information including Customer, Orders and Accounts Info as output.

Copy CustMigrationSplitJoin.wsdl into WSDLs folder of XYZCustomer project from here and create a new folder SplitJoins as shown below.

clip_image002

Creating Split-Join:

Open Service Bus overview editor and drag Split Join into middle swim lane from Components -> Service Bus -> Resources and finish the creation using wizard as shown below. Make sure that you select SplitJoins folder as the location in wizard.

clip_image004

clip_image006

Click Next and select WSDL CustMigrationSplitJoin.wsdl.

clip_image008

Click OK and uncheck Expose as a Proxy Service.

clip_image010

Click Finish. Observe that your Split Join flow should look like below.

clip_image013

Drag Parallel activity after Receive as shown below from Flow Control and add another branch by clickingclip_image014. The Parallel activity allows you to invoke different services concurrently.

clip_image016

In Properties tab, modify Name for all the Scope activities as shown below. Drag Invoke Service activity into each of these Scope activities in all 3 parallel branches from Communication to invoke Business services. Also modify Name property for Invoke activities in Properties tab.

clip_image018

In Properties tab, browse and select CustomerServiceBS, CustomerOrderServiceBS and CustomerAccountServiceBS for Service property of InvokeCustomer, InvokeCustOrder, InvokeCustAccount activities respectively.

clip_image020

clip_image022

Select Operation as shown below for InvokeCustomer, InvokeCustOrder , InvokeCustAccount activities respectively.

clip_image024

clip_image026

clip_image028

For InvokeCustomer, create Request and Response variables as shown below. Request Variable can be created as local variable as you don’t use it outside the scope.

clip_image030

clip_image031

clip_image033

clip_image034

Now your properties tab for InvokeCustomer should look like below.

clip_image035

Similarly create variables CustOrderReq, CustOrderResp for InvokeCustOrder and CustAccReq, CustAccResp for InvokeCustAccount respectively. Local variables created for each Scope activity should look like below.

clip_image037

Your global variables would be shown at Split Join level.

clip_image039

Drag Assign activity from Assign Operations into each of the scope activity and name them as AssignCustInfoReq, AssignCustOrderReq and AssignCustAccReq respectively in Properties tab.

clip_image041

In Properties tab, set properties for AssignCustInfoReq as shown below. This populates request variable with payload for CustomerServiceBS. Since there are not many fields to map, we have chosen this way to populate the payload avoiding new transformations.

Value:

<cust:customerid_input xmlns:cust="urn:xyzbank:cust:schema:customer">

<customer_id>{$request.parameters/customer_id/text()}</customer_id>

</cust:customerid_input>

clip_image042

In Properties tab, set properties for AssignCustOrderReq as shown below. This populates request variable with payload for CustomeOrderServiceBS.

Value:

<ordr:order_input xmlns:ordr="urn:xyzbank:cust:schema:order">

<ordr:customer_id>{$request.parameters/customer_id/text()}</ordr:customer_id>

</ordr:order_input>

clip_image044

In Properties tab, set properties for AssignCustAccReq as shown below. This populates request variable with  payload for CustomeAccountServiceBS.

Value:

<acc:account_input xmlns:acc="urn:xyzbank:cust:schema:account">

<acc:customer_id>{$request.parameters/customer_id/text()}</acc:customer_id>

</acc:account_input>

clip_image045

This would fetch Customer, Order and Account information concurrently by invoking respective business services. And you have to aggregate all these responses before returning back to caller. So you need a transformation to do this.

Create a XQuery map in XQueries folder of XYZCustomer project as shown below. Give name as CustOrderAccountToCustInfo.xqy.

clip_image047

Choose the Source for XQuery map using steps shown below.

clip_image049

clip_image051

clip_image053

clip_image055

clip_image057

Go back to Create XQuery Map window by clicking OK twice.

clip_image059

Similarly add 2 more parameters as shown below to accept Account and Orders information as the input.

clip_image061

clip_image062

clip_image064

clip_image066

Your Create XQuery Map screen should look like below.

clip_image067

Select Target using steps mentioned below.

clip_image068

clip_image070

Click OK twice to finish XQuery map creation and should be visible in XQueries folder as shown below.

clip_image071

Observe the Sources and Target structures and finish the mapping as required and as shown below.  You may want to test your XQuery map using the steps mentioned in this post.

clip_image073

Next step is using this XQuery map in Split Join. Drag Assign after Parallel activity from Assign Operations and set properties as shown below.

clip_image074

clip_image075

clip_image077

clip_image079

clip_image081

With this, you are done with message flow for Split Join and let us finish error handling as well before proceeding with testing. The WSDL used for split join has generic fault structure and you will use the same structure to return all types of faults to caller. So we will do fault handling at Split Join level. Right click CustMigrationSplitJoin and select CatchAll as shown below.

clip_image083

clip_image085

In Properties tab, give the fault variable name as shown below.

clip_image087

Drag Reply activity into Catch All branch from Communication.

clip_image088

In Properties tab, set properties as shown below by creating the new fault variable. This enables Split Join to return fault in case of any error to Pipeline.

clip_image089

Drag Assign activity into Catch All branch before Reply activity from Assign Operations. Modify name to AssignFault and set properties as shown below.

Value:

<custinfo:fault_msg xmlns:custinfo="urn:xyzbank:cust:schema:customerinfo">

<custinfo:error_code>XYZ-0009</custinfo:error_code>

<custinfo:error_message>Error in join operation.</custinfo:error_message>

</custinfo:fault_msg>

clip_image090

Testing Split Join:

Test your Split Join in similar to Proxy service/Pipeline. For my testing, I have used SOAP UI Mock Service to send sample responses to Split Join.

clip_image091

Positive Case:

clip_image093

clip_image095

clip_image097

clip_image099

Negative Case:

clip_image101

Invoking Split Join:

Drag Stage into Request Pipeline of your message flow and set the name as CallSplitJoin. Drag Service Callout from Communication as shown below.

clip_image001

In Properties tab, browse and select CustMigrationSplitJoin for Service property.

clip_image003

Select GetCustomerInfo operation and set other properties of Service Callout as shown below.

clip_image005

sJoinReq is variable to be populated with the payload for GetCustomerInfo operation and sJoinResp is variable that contains response returned by split join after service call. Since you are using ‘Configure Payload Document‘ option, you just need to populate the request variable with required payload.

Drag Assign activity from Message Processing into Request Action of Service Callout and set properties as shown below.

Value:

<urn:customerid_input xmlns:urn="urn:xyzbank:cust:schema:customerinfo">

<customer_id>{$body/cus:CustomerIDInput/CustomerID/text()}</customer_id>

</urn:customerid_input>

clip_image007

Now your CallSplitJoin stage should look like below.

clip_image008[4]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Advertisements

Pages

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 349 other followers

Enter your email address to follow this blog and receive notifications of new posts by email.