![]() |
![]() |
|
|
Handling Workflow Exceptions
The following sections explain how to handle internally and externally generated workflow exception conditions:
Workflow Exception Handling Overview
The workflow exception handling facility enables you to generate, trap, and respond to internally and externally generated exception conditions at run time. Exceptions may be abnormal conditions that you define within the workflow, or they may be typical run-time server exceptions that you trap and respond to accordingly.
Exception handling within WebLogic Process Integrator is performed at the workflow level, rather than at the task level. All workflow template definitions have at least one exception handler, the system exception handler. The system exception handler, is by default, the initial exception handler and is invoked whenever an exception occurs. The system exception handler responds to exceptions by marking the active transaction for rollback only and rethrowing the exception to the client.
The initial exception handler is the handler that is active as soon as WebLogic Process Integrator attempts to create a workflow instance from the workflow template definition. The workflow template definition can change its active exception handler throughout the course of the workflow by using the Set Exception Handler action. Once the workflow invokes the Set Exception Handler action, the initial exception handler becomes inconsequential. The concept of the "initial exception handler" is required, since exceptions can occur prior to a workflow invoking the Set Exception Handler action. For example, exceptions can occur during the initialization of variables in a Start node.
The workflow exception handling facility allows you to define customized exception handlers to act as the initial exception handler and specify actions to be executed in response to exceptions. You set such exception handlers using the Set Workflow Exception Handler action; an exception handler, when set, persists through the workflow instance until the next Set Workflow Exception Handler action is reached within that workflow or until the workflow completes (whichever occurs first).
At any point in its life cycle, a workflow instance has a "current" exception handler. You can change the current exception handler at run-time using the Set Workflow Exception Handler action. You invoke custom exception handlers through use of the Invoke Exception Handler action. Similarly, applications such as custom worklist interfaces can invoke a user-defined exception handler through the following API method: Worklist.invokeWorkflowErrorHandler. Further, you can define an XML document within the Invoke Exception Handler action, allowing workflow variables to be populated by values from this XML document.
Exception handlers have commit and rollback processing paths. You specify certain actions within a workflow to be executed in each of these paths. When an exception occurs, if the currently active transaction is marked for rollback only, the exception handler executes the rollback processing path for the transaction. If the transaction is not marked for rollback only, the exception handler executes its commit path.
The following figure illustrates the workflow exception handling process within WebLogic Process Integrator.
Figure 9-1 Workflow Exception Handling
Defining Exception Handlers
Use the exception handler definition facility to define custom exception handlers to act as the initial exception handler and specify actions to be executed in response to exceptions. If you do not define any exception handlers, the system exception handler is, by default, used. The system exception handler responds to exceptions by rolling back the transaction and rethrowing the exception.
The initial exception handler is the handler that is active as soon as WebLogic Process Integrator attempts to create a workflow instance from the workflow template definition. The workflow template definition can change its active exception handler throughout the course of the workflow by using the Set Exception Handler action.
Note: Once defined, an exception handler cannot be deleted if it is referenced by either the Invoke Exception Handler action or the Set Workflow Exception Handler action. See Using Exception Handling Actions.
To define an exception handler for a workflow template definition within WebLogic Process Integrator, proceed as follows:
Note: You can also define exception handlers by accessing the Exception Handlers tab of the Template Definition Properties dialog box. (See Specifying Workflow Template Definition Properties.)
The Exception Handler Properties dialog box allows you to define actions for commit and rollback exception situations. You can also define workflow variables to be populated by values from the XML message defined within the Invoke Exception Handler action.
Figure 9-2 Exception Handler Properties Dialog Box
Note: Expressions are built using WebLogic Process Integrator expression syntax and typically use the syntax of XPath function to extract values out of XML documents. If you know the syntax of the expression you want to use, you can type the expression directly in the field. Alternatively, click the A+B button to display the Expression Builder dialog box. The Expression Builder helps you construct an expression, which is made up of functions, operators, literals, and variables. For more information on constructing expressions, see Using Expressions and Conditions. Figure 9-3 Workflow Variable Assignment Dialog Box
Note: Certain Enterprise Java Beans (EJBs) can either mark a transaction for rollback only by calling a UserTransaction method, or they can throw an unchecked exception across a container boundary. In either of these two cases, WebLogic Server (WLS) rolls back the transaction.
Using Exception Handling Actions
This section defines and describes how to use the following exception handling actions:
Invoke Exception Handler
Use this action to allow the invocation of a specific exception handler within the workflow. Upon execution of the Invoke Exception Handler action, WebLogic Process Integrator sends the user-defined XML document to the exception processor and invokes the specified exception handler.
To invoke an exception handler, proceed as follows:
Figure 9-4 Add Action Dialog Box
Note: If a plug-in is defined for actions, this dialog box contains the new action. For more information about plug-ins, see Working with Plug-Ins. Note: You cannot invoke an exception handler from within another exception handler. Therefore, if you access the Add Action dialog box from within an exception handler, the Invoke Exception Handler action is not available. Figure 9-5 Invoke Exception Handler Dialog Box
To compose the XML document, perform the actions listed in the following table. The XML document you define is stored in the workflow template definition.
Set Workflow Exception Handle
Use this action to make a specified exception handler the active exception handler for a workflow template definition. If this action is not used in the workflow template definition and no other exception handler is defined and marked as the initial exception handler, the system exception handler, by default, is used and invoked whenever an exception occurs. The system exception handler responds to exceptions by rolling back the transaction and rethrowing the exception.
The exception handler you set for the workflow persists throughout the instance of the workflow until a subsequent Set Workflow Exception Handler action is executed within the same workflow.
Figure 9-6 Set Workflow Exception Handler
View or enter information in the Set Workflow Exception Handler dialog box.
Exit Exception Handler
Use this action to exit an exception handler using one of four methods: rollback, stop, retry, or continue.
Note: This action is only displayed in the Add Actions dialog box when this dialog box is accessed from the Actions on Commit and Actions on Rollback tabs of the Exception Handler Properties dialog box. See Defining Exception Handlers.
Figure 9-7 Exit Exception Handler
View or enter information in the Exit Exception Handler dialog box.
Note: In the Rollback path, the only exit option available in the Exit Exception Handler action is Rollback. When a transaction is rolled back, there are no other options other than rollback.
Certain Enterprise Java Beans (EJBs) can either mark a transaction for rollback only by calling a UserTransaction method, or they can throw an unchecked exception across a container boundary. In either of these two cases, WebLogic Server (WLS) rolls back the transaction.
WebLogic Process Integrator Error Messages
The following is a list of error messages that may be encountered in WebLogic Process Integrator and handled by the exception handler.
To see a list of Workflow Attribute values, see Using Expressions and Conditions. Four error-related values allow you to obtain context about the cause of an exception. These attributes allow the exception handler to interrogate the following information:
Table 9-1 WebLogic Process Integrator Error Messages
![]() |
![]() |
![]() |
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|