- Whitehorses - http://blog.whitehorses.nl -

BPEL 11g threads in parallel flow

Tweet [1]

A lot has been written about the transactions, boundaries, threads etc in the Oracle SOA Suite. Clemens has written this piece years ago which explains the basics [2].I recently had a ‘disagreement’ with the SOA threadpool when I was using a parallel flow [3]in a synchronous BPEL process.

The requirement was to guard the execution time of this BPEL process to a predefined maximum amount of seconds. The environment is as such that tweaking the syncMaxWaitTime, or JTA timeout properties would not be the solution. An Pick activity with an onAlarm doesn’t work either because you can’t create an synchronous BPEL (2.0) instance using an onMessage branch.

The solution is quite simple though. Just create a parallel flow with an Wait activity that waits for the predefined amount of time and then throws an error.

Example of BPEL parallel flow. [4]

Example of BPEL parallel flow.

 

The thing is that a parallel flow isn’t parallel at all. It runs in a single thread. Lets say that the Wait is to be for 20s. And in the “main flow” there is an Invoke activity that takes 30s. This Invoke blocks the thread and the Wait activity will never trigger in time.  Oops.

The solution is straight forward: release the thread! Make the Invoke activity a “nonBlockingInvoke”. Set this property on the specific PartnerLink and the invocation gets its own thread. Your Wait activity will trigger in time.