Operating Systems: i5/OS
Personalize the table of contents and search results
Create an application that uses the business activity
support
To create an application component that uses the business activity
support, set Run EJB methods under a Business Activity
scope in the deployment descriptor of the relevant application
component, and if required, create and specify a compensation handler for
the application to use in the event of an error. You then build the component
into the application and deploy the application onto a server that has the
business activity support enabled. The application component can be either
an enterprise bean or a Web service that is implemented as an enterprise bean.
For information about editing deployment descriptors, refer topics
such as "Application Deployment Descriptor editor", in the Application Server
Toolkit documentation, accessible from the Contents view.
Overview
Perform this task to for an application that runs on a business-activity-enabled
sever to use the business activity support at run time, and to perform work
that might later be compensated by a compensation handler. If the application
requires compensation when a business activity scope ends, the application
passes data that is required by the compensation process, in the form of a
Service Data Object (SDO), to a compensation handler indirectly by using the
business activity API.
Procedure
- Design the application component that requires the business activity
support. In particular, define the application component requirements for
compensation and close activities. If the application component requires compensation,
define the nature of the data in the SDO that the application component passes
to the compensation handler.
- Using the information from your application design, create the
compensation handler for the application component, if required. This
handler defines the close and compensation logic that runs upon completion
of a business activity scope that has the handler added to it through an application
component.
- Open your chosen WebSphere Application Server assembly tool.
- Create a new Java class that implements the com.ibm.websphere.wsba.CompensationHandler
interface.
- Implement the close and compensate methods
on the new compensation handler object, to perform appropriate actions depending
on the SDO data that passes to the handler when it is invoked.
The compensation handler class is now ready for the application
component to reference, and for assembly into an application.
- Open the application component in the assembly tool.
- Open the deployment descriptor for the application component in
the deployment descriptor viewer.
- Scroll to the Compensation section and select
the Run EJB methods under a Business Activity scope check
box.
- In the Compensation handler class text field,
type the fully qualified class name of the compensation handler class that
you created earlier.
- Save the deployment descriptor.
- Build the application, including both the application component
and the compensation handler. If the application is a Web service,
the application must be compliant with the Java Specification Request (JSR)
109 standard.
- Deploy the application onto an application server that is business-activity-enabled.
Results
The application is now business-activity-enabled, and can use the
business activity support at run time through the business activity API. The
application component has a compensation handler associated with it, and can
therefore call the setCompensationDataImmediate and setCompensationDataAtCommit
methods at run time to add the compensation handler to the business activity
scope. For more information about these methods, see Business activity API. If the unit of work with
which the business activity scope is associated fails, the compensation handler
performs actions to compensate for the error.
What to do next
Ensure that the compensation handler class is on the application
class path for the WebSphere Application Server runtime environment.
}
Related concepts
Web Services Business Activity support in WebSphere Application Server
Transaction compensation and business activity support
Assembly tools
Related tasks
Configuring a server to use business activity support
Using the transaction service
Related Reference
Business activity API
Related information
SDO article on developerWorks
|