hi,
in many situations transactions span multiple web requests and i wanted a clean way to handle this.
my thought was to define a WebTransaction object which had a TX ID and a State object. The State is just a Map of objects representing the state during the lifetime of the transaction.
The HttpSession objects holds a Map called TransactionMap which is the Map of WebTransaction objects with Tx ID as key.
With every request, the Tx ID is passed and the appropriate WebTransaction object retrieved from the Map to get State.
The WebTransaction object is created when a transaction is initiated and destroyed(removed from the map) on commit or if an exception occurs at any point during the transaction.
I wanted the groups comments on whether this is a good enough solution or if there are better solutions that anybody is aware of.
Thanks
Raghu
-
transactions spanning multiple requests (1 messages)
- Posted by: raghuram n
- Posted on: February 03 2004 01:32 EST
Threaded Messages (1)
- transactions spanning multiple requests by Mircea Crisan on February 03 2004 02:34 EST
-
transactions spanning multiple requests[ Go to top ]
- Posted by: Mircea Crisan
- Posted on: February 03 2004 02:34 EST
- in response to raghuram n
Hi,
anoher approach would be to use a statefull session bean like :
....
shoppingCart.setCustomer(customerId);
shoppingCart.addItem(item1);
shoppingCart.addItem(item2);
...
shoppingCart..checkout();
//place the order in a processing queue or write something in the database
//remove the bean because is no longer needed
shoppingCart.remove();
...
//or if the users cancels the the shopping cart
shoppingCart.remove();
Advantages:
1. you maintain the state in a more cleaner way that in a map stored in the session.
2. the container takes care of the timeout of the session cart.
3. you can make the shopping cart a remote EJB in order to ease the load off the web server.
Disadvantages:
1. maybe you don't have or don't need an EJB container.