Feeds

Programming constructs in BPEL

Part 3: BPELJ and Compensation

Providing a secure and efficient Helpdesk

The first thing to note in this script is the two attributes for the whole process at the start. These are used to define the default expression language (which in this case is Java) and the default package (bpelj:package="com.regdev.example") that should be used with any emebedded Java code within the script. That is, all Java code should be considered to be part of the com.regdev.example package.

Next, note that the <partnerLinks> section includes a partner link to a "lookup" resource. This is actually a Java class, such as an EJB, that will be used elsewhere within the script.

In the variables section, a new variable message is defined as a type defined by a class TextMessage within a package com:.regdev.

Later in the script, a Java snippet can be seen. A Java snippet contains valid Java expressions or statement blocks. These blocks are embedded in a BPEL process definition and have access to certain variables defined within the execution space of the script (in a similar manner to the way in which JSPs can contain embedded Java code that can access certain variables within a JSP).

Finally, an invoke section illustrates how a method is invoked on a Java class. In this case the method checkRegistration on the class indicates by the partner link referenced by BookLookup (i.e. com.regdev.BookLookup). The method checkRegistration takes two parameters a (book) title and an isbn.

BPELJ - is this the right answer?

In an earlier column, I indicated that BPEL represented Programming in the Large, whereas programming languages such as Java represent Programming in the small. I am left wondering whether there's a fundamental dichotomy between the two approaches. Is it really appropriate to define business functions in Java within a BPEL definition? Does this promote the flexibility claimed for BPM and the use of BPEL?

If we look at the implementation of BPELJ, I'm again left wondering about the success of the final result. The intention, as mentioned earlier, was to use the strengths of both to provide something that is more than the sum of its parts. However, we end up with a syntax that is less than "clean", in my opinion, as a programming language (notably, a criticism I've also been levelling at JSPs for years). Embedding Java within BPEL Java snippets might work well if there was a development tool hiding the details, but in its raw form it's hamstrung by embedding it in an XML-based pseudo-programming language.

Compensation

The idea behind compensation is that in any long running business process, situations may occur in which it's necessary for the whole business process to be terminated tidily. However, within such business processes, the systems being integrated tend to be asynchronous in nature. They may represent both new and legacy applications, may or may not have the ability to rollback any side affects of any services executed etc.

In such situations, when a business process must be terminated, it may be necessary to communicate with one or more systems that have previously completed their activities, in order to tell them to undo what they've done. The goal of compensation is to support the reversal of the effects of previous activities that have been carried out as part of the process now being terminated.

Compensation overview

Having read the introduction, perhaps you are thinking, so what exactly is compensation? I find it useful to think of compensation being used in the following scenario for a holiday booking business process:

To book a holiday we might create a business process that defined three specific steps:

  1. Booking a hotel
  2. Booking a hire car
  3. Booking a flight

In such a scenario compensation behaviour might be defined for each of these steps such that if the hotel and the hire car are booked but a flight cannot be found then the hire car and the hotel booking can be undone - this undoing process is compensation.

In practice, compensation has two parts a compensation handler and a compensate activity. A compensation handler is associated with a "scope". A scope is a container and context for other activities (you might considered it to be analogous to a {}block in Java). For example, the "Booking a Hotel" step above could be a scope. Indeed, the above example could be considered to have three scopes, one for each booking. Thus, each scope would have its own compensation process defined for it. The compensation process is referred to as the "compensation handler" and defines how the compensation is implemented (i.e. how the undo behaviour should be performed).

The compensation handler can also be invoked indirectly by a compensate activity. When this happens the compensation handler is invoked on an inner scope activity that has already successfully completed, and it can be invoked only from within a fault handler or another compensation handler.

Secure remote control for conventional and virtual desktops

More from The Register

next story
'Windows 9' LEAK: Microsoft's playing catchup with Linux
Multiple desktops and live tiles in restored Start button star in new vids
Not appy with your Chromebook? Well now it can run Android apps
Google offers beta of tricky OS-inside-OS tech
New 'Cosmos' browser surfs the net by TXT alone
No data plan? No WiFi? No worries ... except sluggish download speed
Greater dev access to iOS 8 will put us AT RISK from HACKERS
Knocking holes in Apple's walled garden could backfire, says securo-chap
NHS grows a NoSQL backbone and rips out its Oracle Spine
Open source? In the government? Ha ha! What, wait ...?
Google extends app refund window to two hours
You now have 120 minutes to finish that game instead of 15
Intel: Hey, enterprises, drop everything and DO HADOOP
Big Data analytics projected to run on more servers than any other app
prev story

Whitepapers

Secure remote control for conventional and virtual desktops
Balancing user privacy and privileged access, in accordance with compliance frameworks and legislation. Evaluating any potential remote control choice.
Saudi Petroleum chooses Tegile storage solution
A storage solution that addresses company growth and performance for business-critical applications of caseware archive and search along with other key operational systems.
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?
Security for virtualized datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.
Providing a secure and efficient Helpdesk
A single remote control platform for user support is be key to providing an efficient helpdesk. Retain full control over the way in which screen and keystroke data is transmitted.