Using IME to terminate the process
In this process, during the Review Request activity, if a reviewer detects an error and wants to terminate this request without any further investigation, he can press the End Process button. Hence, the End Process can yield an event to the BPD. In this BPD, you can use the IME (event handler) to capture this event and terminate this process.
- Create the UCA to generate the End Process event. The event can come from different sources, one of which is the UCA. In this tutorial, we use the UCA to generate an event. The UCA requires a service to receive and output data. At minimum, the UCA needs one variable for both input and output, which is the correlationID. Because an IME listener lives within an existing process instance when an event occurs, that event must be matched against the correct instance of the process for which the event is destined. The ability to match the event against this correct instance is called a "correlation".
- Define the End Process Service and variables as shown in Figures
15 and 16.
Figure 15. End Process Service diagram
Figure 16. Variable of End Process Service
- Create the UCA for the Release End Process event (Figure 17).
Figure 17. Configuration of End Process UCA
- Re-design the Review Request coach, so that whenever the user
clicks on the End Process! button, the UCA
generates a terminate event for the process. The UCA connects to a
Confirm End Process Coach before reaching the End event, as shown
in Figure 18.
Figure 18. Review Request Coach diagram
- Map the data for the
End Process UCAto
tw.local.request.requestID(current process instance ID). Design the Confirm End Process Coach (Figure 19.)
Figure 19. Design of Confirm End Process Coach
In this coach, you are just displaying a static message to inform the end user:
"Terminate this process".
- Add the IME to the BPD to listen to the End Process event (Figure
Figure 20. BPD diagram after adding the IME
There are two kinds of IMEs: attached IME and inlined IME. In this tutorial, we use the attached IME to listen to the event coming from the
Review Requestactivity. The circled envelop is the newly added IME. However, you need to configure the new IME to listen to the End Process event, released from End Process UCA, and terminate the process with the Terminate Process Event, as shown in Figure 21.
Figure 21. Configuration of the End Process IME
In Figure 21,
Attached UCAis now the
End Process UCA.
checked, which means that you just received the message once.
tw.local.request.requestID, which is used to identify the current process instance ID.
- You can now test this new process by running the process application.
Run the application in the web browser. If you arrive at the
Review Request activity, click on the
End Process! button to terminate the process,
as shown in Figure 22.
Figure 22. UI of Review Request activity on the web
You just went through the steps on how to build an IME to terminate the entire process. The next lesson is to build an IME to restart an activity by pressing the Re-submit Request button in the Review Request Coach.