Tuesday, July 13, 2010

Dynamically updating the BPEL properties-timeout

In this exercise we will see how we can dynamically change the property in bpel.xml.

This exercise i will be discussing of a simple scenarion when in i will call a partnerlink where in i will put a wait activity
which will wait for 10 seconds.

I will further create one more synchronous bpel process which will invoke this partnerlink service with a timeout of 5 seconds
at partnerlink level.

Now in our exercise we will use a java embedded activity to override the value of timeout at partnerlink level.
This is how we will do it.



Create a new synchronous BPEL process





Make it a synchronous bpel process.




Drag and drop a wait activity and put a time out of 10 seconds



deploy this project.

NOw create another BPEL process which will call this partner bpel process

This will also be a synchronous BPEL process.


Your master BPEL process will look something like this.






ONce done these changes

double click on the partnerlink and go to property tab.
YOu need to create two property timeout and optSoapShortcut

Initially i have defined time out as 5 second so it will wait for 5 second to throw timeout error.



we also need to define property optSoapShortcut as false



optSoapShortcut : This property instructs bpel to make the webservice calls via saop stack or not.
When BPEL invokes any partner links if the services its calling is running on the same server/domain then it avoid soap overhead and calls natively.
There may be situations that you want to invoke the services via Soap Stack, then this property helps you do just that.
Timeout property works on soap stack. Suppose a BPEL proces is calling another BPEL process then the call will change from Soap stack to local binding call.



Now once these changes are done deploy this project also and invoke it.Once you will invoke it you will get an error something like this


Your test request was processed synchronously. It took 5.047seconds to finish and generated the following output:
Value:
<Faulthttp://schemas.oracle.com/bpel/extensionhttp://schemas.xmlsoap.org/soap/envelope/>
<faultcode>null:bindingFault</faultcode>
<faultstring>business exception</faultstring>
<faultactor>cx-fault-actor</faultactor>
<detail>
<summary>exception on JaxRpc invoke: HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed: Read timed out</summary>
</detail>
</Fault>

AS you can see the process waits for 5 seconds defined in timeout.

Since the partner process we have defined has a time out of 10 seconds so out partnerlink timeout expire first and we get this error.

So if you want to remove this error then you can just make the time out at partnerlink level more than 10 seconds and the process will work fine.


So this is our Baisc BPEL process scenario now we will see how we can change these values dynamically through java embedding.


NOw drag and drop a java embed activity in your BPEL process.

This should be before the invocation of the partnerlink.



this is the code that i have used in my java embed activity


try {
getLocator().lookupProcess("Master").getDescriptor().getPartnerLinkBindings().getPartnerLinkBinding("Partner1").setPropertyValue("timeout","15");
}catch(Throwable ex) {

}


Here Master is my BPEL process name.
Patner1 is the partnerlink bpel process.
timeout is the property that i have set in partnerlink


Here i have made time out as 15 seonds it will overwrite the time out of 5 seconds that i have specified in partnerlink

so now my overall BPEL process will look something like this




Now again deploy the process and check it again ,now you will find that the process completes successfully

Your test request was processed synchronously. It took 10.532seconds to finish and generated the following output:
Value:
<MasterProcessResponsehttp://xmlns.oracle.com/Master>
<result>asd</result>
</MasterProcessResponse>



Similarly we can also change other properties in BPEL.xml

<preferences>
<property name="preferenceProperty" encryption="plaintext">valueOfPreferenceProperty</property>
</preferences>

<configurations>
<property name="configProperty" encryption="plaintext">valueOfConfigProperty</property>
</configurations>

For these properties we can use the following java code

/*Write your java code below e.g.
System.out.println("Hello, World");
*/
try {
getLocator().lookupProcess("Master").getDescriptor().getConfigurations().setPropertyValue("configProperty", "newValueOfConfigPropertyValue");
getLocator().lookupProcess("Master").getDescriptor().getPreferences().setPropertyValue("preferenceProperty","newValueOfPreferenceProperty");
}catch(Throwable ex) {
}


So instead of specifying the timeout we can get some dynamic values to see its behaviour

something like this



Element inputValue=(Element)getVariableData("inputVariable", "payload","/client:MasterProcessRequest/client:input");

String inputVal=inputValue.getTextContent();
addAuditTrailEntry("Value Entered is : " + inputVal);
try {
getLocator().lookupProcess("Master").getDescriptor().getPartnerLinkBindings().getPartnerLinkBinding("Partner1").setPropertyValue("timeout","inputVal");
}catch(Throwable ex) {

}



This sample takes input value from client and changes the time out as per input variable however i didn't tested it.
If some one test it please let me know your steps or error which you got.

4 comments:

Publishing Editor said...

Anoteher good referenace for BPEL is http://bpelresource.com/

Mikku said...

This is for 10.1.3.X,i have not tried it in 11g,will check and update you on this.

Anonymous said...

If I've 3 bpel on BpelConsole, ex: A, B, and C. I know that default timeout is 45s for all bpel. What I want to do is to set timeout = 10s on Bpel A only, is it possible?

Mikku said...

Time out can be set at process level,domain level and container level.Please have a look in the following post for the same.

http://soa-bpel-esb.blogspot.com/2009/09/timeout-issue-in-bpel-soa-suite.html

http://soa-bpel-esb.blogspot.com/2009/09/timeout-issue-in-bpel-soa-suite.html

http://soa-bpel-esb.blogspot.com/2010/03/setting-timeout-in-11g-for-synchronous.html