Xem mẫu

Handling Events The properties for the alarm handler allow the Alarm type to be configured together with the corresponding timescale as shown in the following figures: With an OnMessage handler, we need to specify which message the handler is going to receive and how this corresponds to the WSDL. The following properties need to be specified. Property Partner Link Port Type Operation Input Variable Description The name of the partner link that is sending the message. The port type defined within the WSDL document for the receiving message. The operation, or method, that is being invoked. The name of the variable within the BPEL process that will store the state of the incoming message. [ 194 ] Chapter 9 In addition to specifying these details within the properties page, they can also be specified within the Property Editor as shown in the figure below. The first tab on the Property Editor dialog allows the properties described above to be specified so you can either enter them within the dialog or directly within the Properties page. As On Message handlers are used within asynchronous processes, it is necessary to specify the correlations used so that the input message can be applied to the correct instance of the running BPEL process. When many instances of the same process are running within the BPEL engine, the engine uses correlations to link together messages from clients to specific instances of running processes. A correlation set is basically a unique piece of information passed from the client to the BPEL engine that can be used to uniquely tie client messages to a running process. A correlation set is rather like a prime key in a relational database. It can contain one piece of data just like the prime key of a database table, or it can consist of multiple pieces of data like a compound key. In this case, the combination of all the data within the correlation set makes up the unique identifier for the process. Correlation sets can be created within NetBeans by right-clicking on the BPEL process within the Design view and selecting the Add | Correlation Set… menu option. On the resulting dialog, we can select the name we wish to give to the correlation set and define which properties from the WSDL file we wish to use to define the set. [ 195 ] Handling Events The correlations tab of the Property Editor allows us to specify which correlation set we wish to use for the specific On Message handler. Compensation Handlers Within BPEL processes, Compensation refers to the ability to undo or roll back activities that have occurred within a particular scope of a running process. A scope in a BPEL process is analogous to a block of Java code that starts with a `{` and ends with a `}`. Typically a scope within a BPEL process represents a particular piece of functionality that is being performed. Within the NetBeans BPEL designer, the scope of blocks of code is represented by a solid rectangle drawn around a block of activities. A Compensation Handler is a BPEL code construct that is executed when a scope is terminated unexpectedly and any processing that has been performed during that scope needs to be undone. NetBeans does not provide any provision for graphical editing of Compensation Handlers within the BPEL designer. To add a Compensation Handler to a BPEL process, we need to switch to the Source view and manually enter the XML for the Compensation Handler. Right-clicking on a scope within the BPEL designer and choosing Goto Source will open the Source view at the beginning of the selected scope. To add a compensation handler, we need to add an XML element for the compensation handler [ 196 ] Chapter 9 Termination Handlers A termination handler is in many respects similar to a compensation handler. The purpose of a termination handler is to provide code to be executed when a BPEL process is unexpectedly exited. Termination Handlers can be applied to any different scope within a process and are defined by the element. The BPEL designer provides no support for designing termination handlers, instead that must be defined within the XML for the process within the Source view of the BPEL designer. The code fragment below shows how a BPEL process may have a compensation handler and a termination handler defined within a particular scope. If no termination handler is defined for a scope then the default termination handler will be invoked. The default termination handler invokes the default compensation handler for a given scope, that is, Summary In this chapter, we`ve looked at the different types of event handlers that can be used within a BPEL process designed within the NetBeans BPEL designer. We`ve seen that there are four different types of event handlers that can be used. Fault Handlers are used for throwing and catching faults rather like the try ... catch and throw constructs within Java code. We`ve seen how we can throw faults and then catch them with specific fault handlers or catch-all handlers. The second type of handlers we looked at were Event Handlers and we discussed how these are used to respond to events—either specific messages or timer messages. Both Fault Handlers and Event Handlers are supported within the NetBeans BPEL designer allowing drag-and-drop of components from within the NetBeans palette into BPEL processes. [ 197 ] Handling Events Next, we looked at compensation handlers and discussed how these are used to rollback data within a BPEL process. Finally we looked at termination handlers and saw how these are called when a BPEL process is terminated unexpectedly. We saw how the default termination handler invokes the default compensation handler within a BPEL process scope. In the next chapter, we`re going to bring all the concepts and techniques we`ve discussed so far together and build a real world enterprise application using NetBeans and the NetBeans Enterprise Pack. [ 198 ] ... - tailieumienphi.vn
nguon tai.lieu . vn