Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Microflow Compensation in Business Process Choreographer

Birgit Duerrstein (duerrstein@de.ibm.com), Developer, IBM Germany
Birgit Duerrstein works in the WebSphere Process Choreographer development team in the IBM development lab in Boeblingen. Birgit joined IBM Germany in 2002 after she completed her studies of Information Technology in Stuttgart. She is now leading the development of samples and scenarios for WebSphere Process Choreographer.
Anke Robeller (anke@de.ibm.com), Developer, IBM Germany
Anke Robeller works in the WebSphere Process Choreographer development team in the IBM development lab in Boeblingen. She joined IBM Germany in 1999 and works since 2001 in the development of the Process Choreographer navigation component. Anke holds a master's degree in computer science from the University of Stuttgart, Germany.

Summary:  Microflow compensation is a new feature in WebSphere Business Integration Server Foundation V5.1 that enables users to define corrective actions for such "side effects" of microflows. This article explains the concept of microflow compensation and provides an example.

Date:  26 Jan 2005
Level:  Intermediate

Activity:  1942 views
Comments:  

Introduction

WebSphere® Integration Server Foundation V5.1 provides a business process engine called Process Choreographer. Business processes can be short-lived and execute in one single transaction -- then, they are called "microflows". Nevertheless, microflows can trigger actions whose effects cannot be undone automatically if the process transaction rolls back.

This article begins with a brief review of the concept of a microflow and how services relate to transactions. Then we explain the microflow compensation itself. The section, Microflow participating in the compensation of a long-running process, shows how the compensation of a microflow can be triggered by a long-running parent process. Finally, we provide a sample that illustrates these concepts.

A basic understanding of Business Process Execution Language (BPEL) and Process Choreographer is assumed.


What is a microflow?

There are two different kinds of business processes in Process Choreographer: Microflows (or non-interruptible processes), and long-running (or interruptible) processes.

Microflows are executed in a unit of work. This means that a microflow completes either successfully as a whole, or not at all. Only after all activities that make up the microflow have completed successfully, the transaction that encloses the business process and all its transactional activities is committed. For example, if an activity in a microflow updates a row in a database table, this database update can participate in the process's transaction and is then committed (or rolled back) together with the business process.

Note: Unit of Work

A unit of work in the context of Process Choreographer microflows may either be an ACID transaction, or an ActivitySession. To simplify matters, we will talk about transactions only in the following -- but at all appearances of "transaction", you could use an ActivitySession or "unit of work" as well.

If a transaction rollback occurs, the complete business process, including all transactional activities is rolled back, for example, the database update that was attempted in a business process activity is rolled back as well. Activities with an implementation that is not transactional remain untouched.

The following figure shows a microflow and its transaction boundaries.


Figure 1. Microflow with Transaction Boundary
Microflow with Transaction Boundary

Process Choreographer processes microflows in memory and in a single thread. Therefore, a microflow executes with very good performance and throughput.

Observe that in the example above, the two activities "Change RoutingNo" and "Change AccountNo" are not processed in parallel, since the complete process is executed in a single thread. In fact, parallel activities in a microflow are executed sequentially. Their execution order in the sequence is not specified. The business process engine can execute them in arbitrary order.

Also, observe that the Process Choreographer database holds no information about process instances of microflows. Since they are executed in memory, no information about the microflow instances is written to the database. All data around microflow instances is transient.

Because a microflow is executed in one single transaction, it cannot contain the following activities:

  • More than one receive or pick activity
  • Staff activities
  • An invoke activity that invokes a request/response operation with an asynchronous binding

If your business process requires one of these features, it must be implemented as a long-running process.


Service invocations and transactions

A service invocation is called transactional with respect to the process, if its effects are completely undone upon rollback of the current transaction and if they are persistently stored upon commit.

For example, a service that is implemented by a Java entity bean's business method is transactional. When the transaction of the microflow rolls back, the changes in the enterprise bean and its underlying database table are not visible.

A service invocation is called non-transactional if its changes to the environment are visible regardless of the outcome of the current transaction.

Samples for non-transaction services are:

  • Sending an email.
  • A SOAP service (since http does not support transactions).
  • The invocation of an enterprise bean with a transactional attribute of "requiresNew".
  • A connector to a legacy system, that does not support the two-phase commit protocol.
  • Writing to the file system.

Microflow compensation

A microflow is compensated if and when the current transaction rolls back. Hence, compensation in a microflow is triggered by the infrastructure, rather than by application logic. The idea of microflow compensation is to reverse the effects of non-transactional services. Microflow compensation is run during the processing of the rollback, thus, neither the effects of transactional nor non-transactional work is visible to the outside world when it comes to a rollback.

A microflow has to be enabled for compensation by setting the compensation sphere descriptor to "required". To tell the process engine what to do upon compensation, the author of a microflow can model or undo services for each invoke activity in his process. In addition, the modeler has to specify whether a forward service is transactional or not. It is important to understand that an undo service can also be tied to a transactional invoke; however, it is never regarded in pure microflow compensation. Correcting actions for transactional work is important, if the unit to compensate has long-running character as outlined in the section, Microflow participating in the compensation of a long-running process.

The undo services are run in reverse order of their forward service's completion time. Only forward services that are completed successfully are undone. For undo services, the same restrictions apply as for services in microflow in general, that is, an undo service cannot be long-running. The undo service gets one input message that represents a snapshot of a process variable taken at the completion time of the forward action. The reverse action is conceptually a one-way function, since its output is ignored.

Figure 2 shows the forward execution and compensation of the microflow "microflow_1". The microflow has four invoke activities: "A", "B", "C" and "D". The service of activity "D" throws an exception that leads to a rollback and thus to compensation. The compensation calls the undo services for "B" and "A". "C" is not compensated, since its forward action is transactional. "D" is not undone because it did not completed successfully.


Figure 2. Microflow compensation
Microflow compensation

Microflow participating in the compensation of a long-running process

As already mentioned in the last paragraph, an undo service can be specified for transactional as well as non-transactional work inside a microflow. The need of undoing transactional work also comes into play, if the decision to compensate is made after the transaction is committed. This is the case if a microflow is called from the context of a long-running process and the microflow thus participates in the compensation of its parent process.

The picture below illustrates the long-running process "long_runner". The second invoke is implemented by the microflow "microflow_1", which we already know from the microflow compensation sample. Compensation in a long-running process is triggered, if a fault reaches the process boundary, that is, if the fault is not caught by a fault handler of enclosing scopes. Let us assume that such a fault happens in the third invoke of the long-running process. At this point preceding transactions are completed and committed.


Figure 3a). Microflow called from a long-running process
Microflow called from a long-running process

The compensation contains the undo services for the first invoke in process "long_runner" together with all four undo services of the microflow. This time also the transactional service "C" has to be compensated, because the transaction of the microflow is already committed.


Figure 3b). Microflow participates in the compensation of a long-running process
Microflow participates in the compensation of a long-running process

Example

Now let's implement the business process "UpdateBankInfo". This business process is used to change the bank information of customers, for example, of credit card holders. It contains the following steps:

  1. Start the process with an update request. You can receive and store the data about the update in a process variable. This includes the customer name, the customer's credit card number, and the new account number. Optionally, a new routing number might be included.
  2. Update the routing number and the account number of the customer in the respective backend system(s). Observe that these updates are transactional in our scenario. For example, we could use entity beans to access the database(s) that holds the bank information. This means that we do not have to specify an <undo> operation for the update activities. If the business process fails, the database updates will automatically be rolled back.
  3. After you've updated the backend system(s) successfully, the process sends a confirmation email to the customers whose bank information has been updated. Sending an email is non-transactional. This means that even though the overall business process has not completed yet (and thus, has not been committed), the email is sent. If the business process, including the database updates are rolled back, the email is still sent.

    Therefore, we specify both do and undo operation for this <invoke> activity.

    Attention: You must not check the box "Activity Takes Part in Transaction", because the email service is not transactional.

  4. To demonstrate the microflow compensation feature of Process Choreographer, you can simulate a server crash after the confirmation email has been sent. You can do this by using a <throw> activity.
  5. To enable Compensation for the UpdateBankInfo process, select Required for the Compensation Sphere attribute. Then, if a fault reaches the outermost scope of the process and is not caught there, Compensation is triggered.

The following image gives an overview of the UpdateBankInfo BPEL process:

Figure 4. Overview of UpdatebankInfo process


When the UpdatebankInfo process is started, the following things happen under the covers:

  1. A new compensation sphere is created for the UpdateBankInfo process. This is because the process has the compensation sphere attribute set to required and it is started stand-alone.
  2. The "Receive Update Info" activity stores the process input data in the UpdateInfo variable.
  3. The "prepChange" activity populates the variables ChangeRoutingNoIN and ChangeAccountNoIN.
  4. The two invoke activities "Change RoutingNo" and "Change AccountNo" are executed. They use the data in their input variables to update the customer's bank information.
    This update is transactional.
  5. The "prep Write Email" activity populates the variable EmailIN.
  6. The invoke activity "Write Confirmation Email" is executed and writes an email to the customer, confirming that his bank information has been updated.
    This activity is non-transactional, and we have a compensation action defined for it. Therefore, the compensation action and its input data are added to this process's compensation sphere.
  7. In our throw activity, we simulate a Server Crash. The transaction in which the UpdateBankInfo process is executed, rolls back. This means that the change to the customer's bank information is not persisted.
  8. Compensation executes all compensation actions that have been registered for this instance of the UpdateBankInfo process in last-in first-out sequence.
    The undo action that we defined for the "Write Confirmation Email" activity is executed. It writes another email to the customer and explains that the update failed.

You can download the WebSphere Studio Application Developer Integration Edition service project for the UpdateBankInfo BPEL process, or get an installable EAR file for the UpdateBankInfo process in the Download section below.


Conclusion

This article presented the concept of microflow compensation and how to define corrective actions for the side effects of microflows.



Downloads

DescriptionNameSizeDownload method
microflowCompensationEAR.zip filemicroflowCompensationEAR.zip.2MBFTP|HTTP
MicroflowCompensation.zip fileMicroflowCompensation.zip.1MBFTP|HTTP

Information about download methods


Resources

About the authors

Birgit Duerrstein works in the WebSphere Process Choreographer development team in the IBM development lab in Boeblingen. Birgit joined IBM Germany in 2002 after she completed her studies of Information Technology in Stuttgart. She is now leading the development of samples and scenarios for WebSphere Process Choreographer.

Anke Robeller works in the WebSphere Process Choreographer development team in the IBM development lab in Boeblingen. She joined IBM Germany in 1999 and works since 2001 in the development of the Process Choreographer navigation component. Anke holds a master's degree in computer science from the University of Stuttgart, Germany.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=33339
ArticleTitle=Microflow Compensation in Business Process Choreographer
publish-date=01262005
author1-email=duerrstein@de.ibm.com
author1-email-cc= Copy email address
author2-email=anke@de.ibm.com
author2-email-cc= Copy email address

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers