Thursday, December 24, 2009

Ensuring only one active BPEL instance for a unique transaction

We noticed some users managed to submit a form more than once that led to the starting of two or more BPEL process instance of the same kind for some long running transactions.

Though any subsequent messages meant for this process were handled and processed by the process manager, it led to data inconsistency issues because of two active processes for the same transaction id.

We went down the familiar path of preventing a user from creating such a condition and it was getting harder and harder to fix it. So we decided to approach it from the process side and this is what we did to enable only one active process instance for a given transaction (correlation id).

- added a new message and an operation namely "ignore"
- implemented an event handler for "ignore" on the process's main scope. This handler did not to do anything other than sinking the message.
- set up correlation on this event handler to match the correlation id of the transaction.
- removed the message and operation from the WSDL for ignore before distributing it to the client to avoid any confusion.

This worked because any attempt to start a new process due to duplicate submissions
fails due to a conflicting receive condition created by the event handler for the main scope. This may dump quite a bit of exceptions in the logs, but it helped!

No comments: