The ActivitySession service
The ActivitySession service provides an alternative unit-of-work (UOW) scope to that provided by global transaction contexts. An ActivitySession context can be longer-lived than a global transaction context and can encapsulate global transactions.
Support for the ActivitySession service is shown in the following figure:
Figure 1. The ActivitySession service. This figure shows the main components of the ActivitySession service in WebSphere Application server. For an overview of these components, see the text that accompanies this figure.
Although the purpose of a global transaction is to coordinate multiple resource managers, enterprise applications often use global transaction context as a "session" context through which to access EJB instances. An ActivitySession context is such a session context, and can be used in preference to a global transaction in cases where coordination of two-phase commit resource managers is not needed. Further, an ActivitySession can be associated with an HttpSession to extend a "client session" to an HTTP client.
ActivitySession support is available to Web, EJB, and Java platform for enterprise applications client components. EJB components can be divided into beans that exploit container-managed ActivitySessions and beans that use bean-managed ActivitySessions.
The ActivitySession service provides a UserActivitySession API available to enterprise application components that use bean-managed ActivitySessions for application-managed demarcation of ActivitySession context. The ActivitySession service also provides a system programming interface for container-managed demarcation of ActivitySession context and for container-managed enlistment of one-phase resources (resource manager local transactions (RMLTs)) in such contexts.
The UserActivitySession interface is obtained by a Java Naming and Directory Interface (JNDI) lookup of java:comp/websphere/UserActivitySession. This interface is not available to enterprise beans that use container-managed ActivitySessions, and any attempt by such beans to obtain the interface results in a NotFound exception.
A common scenario is an enterprise application accessing one or more enterprise beans backed by non-transactional (one-phase commit) resources. The application, or its container, uses the UserActivitySession interface to define the demarcation boundaries within which operations against the enterprise beans are grouped and to control whether those grouped operations should be checkpointed or discarded. The business logic of the enterprise beans does not need to use any ActivitySession interfaces. The container into which the enterprise beans are deployed ensures that updates to the underlying one-phase resource managers are coordinated.
The application can checkpoint an ActivitySession to create a new point of consistency within the ActivitySession without ending the ActivitySession. The application can also use a reset operation to return work performed in the ActivitySession back to the last point of consistency. The application can end the ActivitySession with an operation to either checkpoint or reset all resources.
Subtopics
- Usage model for using ActivitySessions with HTTP sessions
This topic describes how a Web application that runs in the WebSphere Web container can participate in an ActivitySession context.
- ActivitySession and transaction contexts
This topic describes the hierarchical relationship between transaction and ActivitySession contexts. This relationship, defined by the ActivitySession service, requires that any transaction context be either wholly inside or wholly outside an ActivitySession context.
- ActivitySession and transaction container policies in combination
This topic provides details about the relationship between the deployment descriptor properties that determine how the container manages ActivitySession boundaries.
- ActivitySession samples
WebSphere Application Server provides some ActivitySession samples.
- ActivitySession service: Resources for learning
Use the links in this topic to find relevant supplemental information about ActivitySessions. The information resides on IBM and non-IBM Internet sites, whose sponsors control the technical accuracy of the information.
Related concepts
ActivitySession service APIs
Related tasks
Develop an enterprise application to use ActivitySessions Concept topic