Business activities
Business activities govern long-running, complex service activities. Hours, days, or even weeks can pass before a business activity is able to complete. During this period, the activity can perform numerous tasks that involve many participants.
What distinguishes a business activity from a regular complex activity is that its participants are required to follow specific rules defined by protocols. Business activities primarily differ from the also protocol-based atomic transactions in how they deal with exceptions and in the nature of the constraints introduced by the protocol rules.
For instance, business activity protocols do not offer rollback capabilities. Given the potential for business activities to be long-running, it would not be realistic to expect ACID-type transaction functionality. Instead, business activities provide an optional compensation process that, much like a "plan B," can be invoked when exception conditions are encountered (Figure 6.27).
Figure 6.27. A business activity controls the integrity of a service activity by providing participants with a "plan B" (a compensation).
Note
The concepts discussed in this section are derived from the WS-BusinessActivity specification, which (like WS-AtomicTransaction) provides protocols for use with WS-Coordination. The WS-Coordination overview section in Chapter 16 contains a brief example of how a coordination type referencing WS-BusinessActivity exists within a SOAP header.
6.5.1. Business activity protocols
As with WS-AtomicTransaction, WS-BusinessActivity is a coordination type designed to leverage the WS-Coordination context management framework. It provides two very similar protocols, each of which dictates how a participant may behave within the overall business activity.
- The BusinessAgreementWithParticipantCompletion protocol, which allows a participant to determine when it has completed its part in the business activity.
- The BusinessAgreementWithCoordinatorCompletion protocol, which requires that a participant rely on the business activity coordinator to notify it that it has no further processing responsibilities.
Business activity participants interact with the standard WS-Coordination coordinator composition to register for a protocol, as was explained in the previous Coordination section.
6.5.2. The business activity coordinator
When its protocols are used, the WS-Coordination controller service assumes a role specific to the coordination typein this case it becomes a business activity coordinator (Figure 6.28). As explained in the previous section, this coordinator has varying degrees of control in the overall activity, based on the coordination protocols used by the participants.
Figure 6.28. The business activity coordinator service model.
6.5.3. Business activity states
During the lifecycle of a business activity, the business activity coordinator and the activity participants transition through a series of states. The actual point of transition occurs when special notification messages are passed between these services.
For example, a participant can indicate that it has completed the processing it was required to perform as part of the activity by issuing a completed notification. This moves the participant from an active state to a completed state. The coordinator may respond with a close message to let the participant know that the business activity is being successfully completed.
However, if things don't go as planned during the course of a business activity, one of a number of options are available. Participants can enter a compensation state during which they attempt to perform some measure of exception handling. This generally invokes a separate compensation process that could involve a series of additional processing steps. A compensation is different from an atomic transaction in that it is not expected to rollback any changes performed by the participating services; its purpose is generally to execute plan B when plan A fails.
Alternatively, a cancelled state can be entered. This typically results in the termination of any further processing outside of the cancellation notifications that need to be distributed.
What also distinguishes business activities from atomic transactions is the fact that participating services are not required to remain participants for the duration of the activity. Because there is no tight control over the changes performed by services, they may leave the business activity after their individual contributions have been performed. When doing so, participants enter an exit state by issuing an exit notification message to the business activity coordinator.
These and other states are defined in a series of state tables documented as part of the WS-BusinessActivity specification. These tables establish the fundamental rules of the business activity protocols by determining the sequence and conditions of allowable states.
6.5.4. Business activities and atomic transactions
It is important to note that the use of a business activity does not exclude the use of atomic transactions. In fact, it is likely that a long-running business activity will encompass the execution of several atomic transactions during its lifetime (Figure 6.29).
Figure 6.29. Two atomic transactions residing within the scope of a business activity.
6.5.5. Business activities and SOA
Business activities fully complement the composable nature of SOA (Figure 6.30) by tracking and regulating complex activities while also allowing them to carry on for long periods of time. Service autonomy and statelessness are preserved by permitting services to participate within an activity for only the duration they are absolutely required to. This also allows for the design of highly adaptive business activities wherein the participants can augment activity or process logic to accommodate changes in the business tasks being automated. Through the use of the compensation process, business activities increase SOA's quality of service by providing built-in fault handling logic.
Figure 6.30. A business activity relating to other parts of SOA.
As with WS-AtomicTransaction, support of the WS-BusinessActivity extension by multiple solutions promotes inherent interoperability and can greatly simplify integration architectures. Business activities take this a few steps further, though, by allowing the scope of the activity to include interaction with outside business partners. (Note that there is nothing restricting atomic transactions from being utilized across organizations. However, business activities are typically more suitable for this type of communication.)
SUMMARY OF KEY POINTS |
---|
|