Thursday, June 15, 2006

Lifetime Management with BPEL (Part II)

It's time now to explain to the reader what I mean using the term "Lifetime Management".

The basic idea is handling the timeouts as they were previously defined before (see Lifetime Management with BPEL (Part I) with BPEL Peek example).

Standard BPEL allows us to handle duration or deadline timeouts by defining how much time should elapse before the timeout event will occur or by specifying the deadline date and time for the deadline (onAlarm's for and until attributes accordingly).

The new way I'd like to declare the process timeout expression is so that onAlarm can handle an automatic duration prolongation in the case when some of the duration expression conditions were changed. It's important to notice that you can not just change onAlarm's expression via, say, Assign activity (at least I couldn't found the way how to do that, so please inform me if you know the way).

Lets take an example of how to use this functionality.

Imagine a web shop that keeps a personal shopping cart for each of its customers.

A user may surf through the web shop, put some products in the cart and make an order.

One of usecases for this web shop may be the following:

  • Customer wants to buy everything he placed in the cart (the good one :). In this case the system calculates an order and starts the process of billing and delivery of the products to the user;
Another possible usecase is:
  • Customer leaves the webshop page (doesn't matter how - by navigating to another URL or just closes the browser window).
What should become with a customer's shopping cart and all the goods that he placed into it in the last scenario? Should we release all the items from the cart immediately? But what if the user will return to the page and act as in the first use case? Then he would have to navigate the site once again and take all the stuff he already did few time ago - bad usability.

On the other hand if we left the items in the cart forever then no one other would be able to buy the stuff that is in the other user's cart since it's already reserved.

So we need to specify the cart lifetime somehow so that all the items were released and the cart were cleared after the specified time.

The typical solution for a web shop here nowadays is using HTTP session but as we are talking about Web Services the HTTP session is not suitable for that. So we may use BPEL that can give us the functionality we need at the higher level of abstraction.

Why not just use BPEL onAlarm duration (the for attribute)? Since, as I already said above, it is not possible to change the duration expression at runtime while this is required to set the new cart lifetime after each cart update (say after adding new item to cart).

In the next part we'll see how to implement this example using BPEL and discuss some key aspects that you should pay attention for while using BPEL here...

0 комментария(ев):