开发者

how to prepogate transaction for multiple request

can we propagate transaction for multiple request. for example in online buying.

user select line items and

step 1: after selecting items when he clicks the button the items should be searched in a warehouse table for required quantity is available or not. afte开发者_JAVA百科r searching it will display table of items with availability.

step 2: user clinks process than the available items are deducted from warehouse table and calculates total and display the order table.

step 3: than user clicks check out button and enters the credit card details an the order is processed.

i want all these three steps should execute in one transaction. is it possible in spring transaction management.


In theory it is possible but would be very poor idea. The reason it's bad idea is that user may, for example, go for lunch before completing transaction and you will have database objects locked for all this time preventing , in the worst case scenario, your system from functioning.


Yes, this actually is only one process, spread across three steps, but the transaction should not actually begin until the user has commmitted the purchase. If the user aborts the process in the middle (e.g., abandons a non-empty shopping cart), no DB or CC transaction should have been begun. Execute the tx at the very end of the process only, and at that point do both DB and CC processing in one shot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜