To throw the fault and to exit the process, we will perform the following steps:
BookWarehousingBPEL
process. We will drag-and-drop the <throw>
activity to the message event handler scope.<throw>
activity ThrowCancelInstance
.ThrowCancelInstance
activity and then specify the Fault QName. The Namespace URI is the same as for the BPEL process itself: http://packtpub.com/Bookstore/BookwarehousingBPEL
. The Local Part name should be CancelInstance
. We will not specify the Fault Variable as the BPEL faults do not require a variable:<exit>
activity and place it after the <throw>
activity. This way the process will terminate. We should see the following BPEL diagram:We have added activities that will execute once the OnEvent
message handler is triggered. We have decided to throw a fault and to exit the process instance. The following code has been generated:
With this, we have concluded our discussion on event handlers. We are now ready to deploy and test the example.
We will deploy the example process the same way as we did in Chapter 9, Human Tasks. Please note, however, that you should either check the overwriting of any existing composites with the same revision ID, undeploy the previous example, or use a higher revision ID; otherwise, you will get an error stating that you cannot overwrite an existing version of an SOA composite.
After the deployment, initiate a BPEL process instance. The instance should wait at the human task, which you can see from Flow Trace:
After 15 minutes, you will see that the alarm event handler has been triggered and the process has been aborted:
This confirms that our alarm event handler has been triggered. We can see that the termination happened exactly 15 minutes after the BookWarehousingBPEL
process was invoked.