Last week, we looked at the assign and other basic activities, and studied flow. This week, we'll be examining more sturctured activities, and fault handling. This article, the fifth in a six-part series, is excerpted from chapter 12 of Building Web Services with Java: Making sense of XML, SOAP, WSDL, and UDDI, written by Steve Graham et al. (Sams; ISBN: 0672326418).
Fault Handling with Web Services - Event Handling (Page 4 of 4 )
Event handlers can be associated with a scope or a process for concurrent processing of events. BPEL defines two types of events:
Message event—Implements a request-response or one-way operation invoked by a business partner
Alarm event—Implements timer-driven behavior
When a scope is active, then event handlers attached to the scope are enabled to receive concurrent messages or alarm events. They are disabled when the processing of the scope ends. Events can only be processed when the corresponding event handler is enabled. When the event handlers for a scope become disabled, running event handlers are allowed to complete. The scope is terminated when all event handlers have completed processing.
During the processing of message events, the event handler remains enabled. Therefore, it can concurrently process multiple events of the same type. In addition to flow activities, this is the second place in BPEL where concurrency is possible. Note that event handlers for a process can't create new process instances.
If an alarm event handler is specified with a duration, then this duration starts when the event handler for the scope is enabled.
In the following example, an event handler is defined that allows a partner to end the lifecycle of the process instance:
If a buyer chooses to cancel a previously submitted purchase order, the cancellation request is processed by a concurrent event handler. The correct process instance is located using the correlation set definition introduced earlier. In this sample, the event handler is implemented by a terminate activity, which causes the activities on all parallel branches of the process to stop immediately.
Please check back next week for the conclusion of this article.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.