Best Practices: SOA Application Design Analysis

Handling faults and exceptions

Exception handling is important to any business process because things will go not as planned in the real world. Some of the exceptions that can occur in a business process can be anticipated at design time, such as certain faults being returned by a service. Some exceptions are hard to anticipate until you actually encounter them at runtime, such as an inbound message that conforms to the message definition but violates one of the underlying business rules (for example, a social security number that starts with '000') or the unavailability of a partner service.

Handling anticipated exceptions

For exceptions that can be anticipated, fault handling logic can be built in the process itself. There are two parts to this – the first part is to catch the exception based on some identifier. Because a fault in one process may cause a ripple effect in other processes, it is crucial to identify and define these potential faults at the early stage of design. You may add fault handling code gradually at a later stage.

BPEL provides a structured mechanism for exception handling and a unit of work in a process can be organized into more granular unit called a scope, for which a discrete fault handler can be specified. BPEL enforces the integrity of the fault handling logic by propagating the faults from an inner scope to its enclosing scopes. ActiveVOS also extends this concept to sub-processes.

As part of exception handling, it is sometimes necessary to roll back changes that have already been committed in order to maintain the integrity and atomicity of a unit of work in a way similar to rolling back an ACID transaction. Because business processes tend to be long running and orchestrated services are loosely coupled and may cross organization boundaries, it is not always practical or desirable to hold changes to resources in an uncommitted state. BPEL provides a solution in the form of an structured compensation handler, which allows for logic that explicitly rolls back changes. BPEL also maintains the consistency of this mechanism by traversing the compensation handler chain from and outer scope to its enclosed scopes that ActiveVOS also extends support for with sub-processes. A key requirement of implementing a compensation handler is to identify the partner interfaces for compensation.

To learn more about fault handling, please review the Handling Faults section.

Handling runtime exceptions

For exceptions that cannot be predicted until it happens (and as such, cannot be handled in the process itself), the consequences may be severe and you may need to find ways to alleviate them in accordance to the business requirements. In order to be able to take actions you need to be alerted when such exceptions occur. ActiveVOS provides runtime alert services that can be used to generate notification and trigger other actions when an unhandled exception occurs. ActiveVOS can also suspend such processes rather than let it terminate.

The alert service can be used for recovery purposes as well, as it will receive the full details of the exception. More often than not, it requires human involvement to correct the condition that causes the fault and conduct the recovery manually. For example, a fault caused by a typo in a social security number may require manual correction of the error in the message variable and retry the failed step in the process. ActiveVOS provides an interface for facilitating such recovery activities.

Some may consider this similar to what a human workflow would do - the important difference being that a human task may be used in a business process to handle predictable exception conditions as part of the process flow, whereas the suspend-retry function is suitable for runtime error recovery. To help handle uncaught exceptions handled by the alert services, consider creating a process containing a people activity. This person can then use ActiveVOS exception management capabilities to fix the process.

To learn how to use ActiveVOS exception management capabilities, please view the Viewing and Fixing Running Processes podcast (video link - registration required).