Wednesday, March 31, 2010

AIA BPEL Dynamic Partnerlink Lookup

BPEL dynamic partnerlink lookup concept is quite old and been there since 10.1.2 and it works great. AIA took that concept little far and forced the design pattern. E.g. all endpoint URLs should be strictly in AIAConfigurationProperties.xml file.

Example would be:

Step 1: put the endpoint URL in AIAConfigurationProperties.xml file:



Step 2: Change the BPEL code to look up this URL at run time using Java Embed.



Step 3: Follow the same old rule for BPEL dynamic partner-link once we have the right endpoint URL.



So far so good, but the problem is 20 lines of "non reusable" java embed code in my BPEL. If you talk with any decent Oracle SOA guru, they will ask you to avoid Java Embed as much as possible. AIA design pattern didn't stop here, they have recommended not to put EndPoint (or Partner-link) name directly in your Java Embed. Reason seems to quite obvious, you just specify the partner-link name, and based on SystemID or CAVS parameter, we can route it to any place without doing any code change. At the end your Java Embed looks something like this:

AIAConfigurationProperties.xml:


Java Embed:





Functional point of view it looks great, but technically - holy crap! 93 lines of non reusable code copied for every partner-link and every BPEL process.


I took initiative to eliminate the code for and obviously the best option was to use Oracle BPEL XPath Function. Initial functionality didn't take long time to develope BPEL function and register them to BPEL RT engine, but making addAuditTrailEntry working in my custom function was an amazing experience. Rather than going too much into details, would just go with final product. I created two separate bpel functions:

1) ora:getSimpleDynamicURL (simpler version)

This function gets dynamic URL from AIAConfigurationProperties.xml.
The signature of this function is : ora:getSimpleDynamicURL ('serviceName', 'partnerlinkName', 'auditTrail'?)
auditTrail: true/false, it is optional and default value is true.


2) ora:getDynamicURL (richer version)

This function gets dynamic URL from AIAConfigurationProperties.xml.
The signature of this function is : ora:getDynamicURL ('serviceName', 'partnerlinkName', 'ebmMsgBpelVariableName', 'ebmMsgPartName', 'auditTrail'?)
auditTrail: true/false, it is optional and default value is true.


If I look at my BPEL process now, it looks like the way it supposed to. I can get TargetEndpointLocation from AIAConfigurationProperties.xml based on parameters, and hallelujah!



It just reminds me the most basic programming tip which my friend told me: "Don't do copy and paste, just do cut and paste.

2 comments:

NN said...

Hi…
i need to learn dynamic partner link from basics.. can u provide me sample example as soon as possible

Thanks
Nayana

NN said...

Hi…
i need to learn dynamic partner link from basics.. can u provide me sample example as soon as possible

Thanks
Nayana