Let us Consider a web transation called AppendText


#appendText(reportId, appendText)
#Append the passed in text to the identified report
request.appendText.classname=com.ai.db.DBPreTranslateArgsMultiRequestExecutor
request.appendText.db=reportsDB
request.appendText.query_type=update
request.appendText.request.1=AT.GetText
request.appendText.request.2=AT.ConcatenateText
request.appendText.request.3=AT.UpdateText
request.appendText.request=AT.UpdateDate

If the above transaction succeeds


request.appendText.redirectURL=\
/akc/servlet/DisplayServlet?\
    url=DisplayNoteMPURL&\
    reportId={reportId}\
    &ownerUserId={ownerUserId}

com.ai.db.DBPreTranslateArgsMultiRequestExecutor

This is a database part that is aware of a transactional context. It's configuration inolves two additional parameters as shown here


request.appendText.classname=com.ai.db.DBPreTranslateArgsMultiRequestExecutor
request.appendText.db=reportsDB
request.appendText.query_type=update

From this it knows to acquire a connection from a aliased data source name called reportsDB. From "update" it knows that this requires a transaction boundary. In addition this is a composite work flow part invoking other parts as part of its definition. In the above case it has 4 requests. If any of them fails then the transaction is rolled back.

How come the following sub part won't commit


#final update
request.AT.UpdateText.classname=com.ai.db.DBRequestExecutor2
request.AT.UpdateText.query_type=update
request.AT.UpdateText.stmt=\
   update sql_statements \
   set statement={newText.quote} \
   where statement_id = {statementId}

Because there is a concept of a connection owner. Being called in a pipeline this part knows that he is not the owner and hence won't commit. If this part were to be invoked directly then it will commit

Manually controlling transactions

If you were to pass a connection as part of the hash table to invoke the pipeline, then the pipeline knows it is not the owner and will abstain from any commit activity. Then it is the responsibility of the caller to decide the commit boundaries.

Additional transactional strategies worth studying

1. Thread based control for
2. Part insertion based
3. JTA

References

1. General Introduction to other Server side Patterns in this series

2. OSCON 2004 Summary page for Server side patterns session