Friday, June 8, 2012

WebSphere Commerce Transactions

Throughout the execution of a controller command, data is often created or updated. In many cases, the database must be updated with the new information at the end of the transaction. The transaction is managed by the Web controller.

The Web controller marks the beginning of the transaction before calling the controller command. When the execution of the controller command is complete,
the controller command returns a view name to the Web controller.

The Web controller is responsible for marking the end of the transaction. The actual point at which the transaction ends (before or after invoking the view) depends upon the type of view used (forward view command).

The Web controller determines the view command to be used for the view by looking up the view name in the struts config file. If the entry in the struts config file specifies the use of the ForwardViewCommand, then the Web controller forwards the results of the controller command to the corresponding
ForwardViewCommand implementation class. The view command executes within the context of the current transaction. In this case, the database commit or rollback does not occur until the view command completes.

In the cases where the view command executes under the same transaction scope as the controller command, an error in the view command causes a rollback of the entire transaction. This may or may not be the desired outcome, depending upon your business logic.

No comments:

Post a Comment