The entire BPEL process as well as each individual Scope can be associated with a set of Event Handlers that are invoked concurrently if the corresponding event occurs. The actions taken within an Event Handler can be any type of activity, such as Sequence or Flow. The only immediate child of an Event Handler is Scope, so when you drag an element from the Palette into an Event Handler, it is automatically wrapped in Scope.
There are two types of events:
Incoming messages, which correspond to a request/response or one-way operation in WSDL. These messages are specified using the On Event elements.
Alarms, or timers, which invoke activities after the specified periods or when a deadline is reached. The times are specified using the On Alarm elements.
Event handlers do not interfere with the main flow of the business process. If an event occurs, and an event handler is executed, the main flow will be executed also.
This means, one shouldn't use event handlers, for example, to send replies to requests received in the main flow, because the main flow might also send a reply which will never be seen by the client, and this can lead to various issues.
On the contrary, a good use-case for event handlers would be to request a business process status. In this case, the activities in the event handler will collect data about the state of the business process, and then reply to the request that triggered the event handler.
This picture can be a bit misleading. The request should be caught by handler itself but not by an internal Receive. I mean that the inbound arrow should come to handler itself, but not to an internal circle, which can be treated like a receive.
Right-click the Process element or any Scope and choose Add -> Event Handlers.
Once you have added an Event Handlers container, you can right-click on the Event Handlers element to add an On Event or On Alarm branch. You may add as many specific On Event or On Alarm elements as you wish, to the Event Handlers group.
The On Event element indicates that the specified event waits for a message to arrive. The interpretation of this tag and its attributes is very similar to a Receive activity.
Right-click the Event Handlers container and choose Add > On Event.
Double-clicking the On Event element opens a Property Editor where you can specify/change the following:
The partner link
The operation associated with the On Event element
The event variable
Right-click the On Event element and choose Properties to open a Properties window to review and modify the properties of the element. In addition to the properties present in the Property Editor dialog box, the Properties window contains the Port Type and Type field.
The Correlations tab in the On Event Property Editor dialog box enables you to examine or specify a correlation set.
The tab shows:
A correlation sets' name
The initiation of a correlator
For more information see Understanding Correlation. Using the Correlation Wizard.
The On Alarm element specifies the deadline for or the duration of the nested Scope.
The properties of the On Alarm element are defined in the Properties window, invoked by right-clicking the element on the diagram and choosing Properties. The available properties are:
Alarm Type is used to choose the type of alarm. The available options are:
For — Sets the duration for the process to wait.
Until — Specifies the deadline for the process.
Repeat Every — . Specifies the frequency of process initiation. It initiates the process each time the specified duration period expires. The clock for the very first duration starts when the associated scope starts.
For + Repeat Every — Specifies the frequency of process initiation after the duration of a specified wait time. The process is initiated each time the duration period specified in the Repeat Every field expires. The first alarm is fired when the period of time specified in the For field expires.
Until + Repeat Every — Specifies the frequency of process initiation based on the specified deadline. The process will be initiated each time the duration period specified in the Repeat Every field expires. The first alarm is fired when the deadline specified in the Until field is reached.
The second (and third, where available) property is used to specify the duration or deadline for the selected alarm type.