summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/rdb-das-transaction-control.html
diff options
context:
space:
mode:
Diffstat (limited to 'site/trunk/site-publish/rdb-das-transaction-control.html')
-rw-r--r--site/trunk/site-publish/rdb-das-transaction-control.html268
1 files changed, 268 insertions, 0 deletions
diff --git a/site/trunk/site-publish/rdb-das-transaction-control.html b/site/trunk/site-publish/rdb-das-transaction-control.html
new file mode 100644
index 0000000000..26c0a65abd
--- /dev/null
+++ b/site/trunk/site-publish/rdb-das-transaction-control.html
@@ -0,0 +1,268 @@
+
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE- 2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<HTML>
+ <HEAD>
+ <!-- generateKeywords macro -->
+ <META name="description" content="Apache Tuscany">
+ <META name="keywords" content="apache, apache tuscany, tuscany, service, services, fabric, soa, service oriented architecture, sca, service component architecture, das, sdo, csa, ruby, opensource">
+ <!-- generateKeywords macro end -->
+
+ <LINK type="text/css" rel="stylesheet" href="http://tuscany.apache.org/stylesheets/default.css">
+ <LINK rel="SHORTCUT ICON" href="https://cwiki.apache.org/confluence/display/TUSCANY/$images/favicon.ico">
+ <TITLE>Apache Tuscany : RDB DAS - Transaction Control</TITLE>
+ <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
+
+ <BODY onload="init()">
+ <!-- topNav macro -->
+ <TABLE valign="top" border="0" cellspacing="0" cellpadding="0" width="100%" background="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg">
+ <TR>
+ <TD valing="top" align="left">
+ <A href="https://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=TUSCANY&title=$siteroot"><IMG src="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg" height="91" width="25" border="0"></A>
+ </TD>
+ <TD>
+ <A href="http://tuscany.apache.org/"><IMG src="http://tuscany.apache.org/images/TuscanyLogo.jpg" border="0"></A>
+ </TD>
+
+ <TD width="100%">
+ &nbsp;
+ </TD>
+
+ <!-- Adds the edit page link to the top banner-->
+ <TD valign="bottom">
+ <DIV style="padding: 2px 10px; margin: 0px;">
+ <A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=66405">
+ <IMG src="http://tuscany.apache.org/images/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
+ </DIV>
+ </TD>
+
+ </TR>
+ </TABLE>
+ <!-- topNav macro end -->
+
+ <!-- breadCrumbs macro -->
+ <TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
+ <TR class="topBar">
+ <TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%">
+ &nbsp;<A href="home.html" title="Apache Tuscany">Apache Tuscany</A>&nbsp;&gt;&nbsp;<A href="home.html" title="Home">Home</A>&nbsp;&gt;&nbsp;<A href="das-overview.html" title="DAS Overview">DAS Overview</A>&nbsp;&gt;&nbsp;<A href="das-java.html" title="DAS Java">DAS Java</A>&nbsp;&gt;&nbsp;<A href="das-java-documentation-menu.html" title="DAS Java Documentation Menu">DAS Java Documentation Menu</A>&nbsp;&gt;&nbsp;<A href="" title="RDB DAS - Transaction Control">RDB DAS - Transaction Control</A>
+ </TD>
+
+ <TD align="right" valign="middle" class="topBarDiv" align="left" nowrap="true">
+ <A href="http://mail-archives.apache.org/mod_mbox/tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>&nbsp;&nbsp;
+ </TD>
+ </TR>
+ </TABLE>
+ <!-- breadCrumbs macro end -->
+
+
+ <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
+ <TR>
+ <TD align="left" valign="top">
+
+ <!-- pageContent macro -->
+ <DIV id="PageContent">
+
+ <DIV class="pagecontent">
+ <DIV class="wiki-content">
+ <TABLE class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><TBODY><TR>
+<TD class="confluenceTd" valign="top" width="15%">
+<DIV class="panel" style="background-color: #ECF4D1;border-color: #C3CDA1;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #C3CDA1;background-color: #C3CDA1;"><B>General</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
+<P><A href="home.html" title="Home">Home</A><BR>
+<A href="http://www.apache.org/licenses/LICENSE-2.0.html" class="external-link" rel="nofollow">License </A><BR>
+<A href="das-java-get-involved.html" title="DAS Java Get Involved">Get Involved</A><BR>
+<A href="das-java-found-a-bug.html" title="DAS Java Found A Bug">Found a Bug?</A></P>
+</DIV></DIV>
+<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>DAS Java</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
+<P><A href="das-java.html" title="DAS Java">DAS Java Home</A><BR>
+<A href="das-java-faq.html" title="DAS Java - FAQ">FAQ</A><BR>
+<A href="das-java-releases.html" title="DAS Java Releases">Downloads</A><BR>
+<A href="das-java-documentation-menu.html" title="DAS Java Documentation Menu">Documentation</A><BR>
+<A href="https://svn.apache.org/repos/asf/tuscany/java/das/" class="external-link" rel="nofollow">Source Code</A></P>
+</DIV></DIV></TD>
+<TD class="confluenceTd" valign="top" width="85%">
+<DIV class="panel" style="background-color: #ffffff;border-color: #ECF4D1;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #ECF4D1;background-color: #ECF4D1;"><B>Transaction Management in RDB-Data Access Service (RDB DAS)</B></DIV><DIV class="panelContent" style="background-color: #ffffff;">
+<UL>
+ <LI><A href="#RDBDAS-TransactionControl-Overview">Overview</A></LI>
+ <LI><A href="#RDBDAS-TransactionControl-DASmanagedtransactions">DAS managed transactions</A></LI>
+ <LI><A href="#RDBDAS-TransactionControl-Externallymanagedtransactions">Externally managed transactions</A></LI>
+</UL>
+</DIV></DIV>
+
+<H3><A name="RDBDAS-TransactionControl-Overview"></A><A name="RDBDAS-TransactionControl-Overview"></A>Overview</H3>
+
+<P>A typical enterprise application accesses and stores information in one or more databases. Data integrity is <BR>
+the most essential aspect of correct business functioning. Transactions control the concurrent access of data <BR>
+by multiple programs. In the event of a system failure, transactions make sure that after recovery the data will<BR>
+ be in a consistent state. This document helps to understand transaction management in RDB DAS.</P>
+
+<P>One DAS instance is always associated with one database and one Connection. DAS participates in <BR>
+<B>A&gt; DAS managed and B&gt; Externally managed transactions</B>.</P>
+
+<H3><A name="RDBDAS-TransactionControl-DASmanagedtransactions"></A><A name="RDBDAS-TransactionControl-DASmanagedtransactions"></A>DAS managed transactions</H3>
+
+<P>By default, the RDB DAS assumes responsibility for managing transaction boundaries by executing commit and <BR>
+rollback operations against the database. A configuration attribute managedtx is assumed with default value <BR>
+TRUE. This signals DAS to control the transaction. The boundaries of these transactions are as follows:</P>
+
+<P><B>Reading Data</B><BR>
+Queries to the database are always made by calling DAS command's &quot;executeQuery()&quot; method. The associated <BR>
+transaction lives for the duration of this method execution. That is, the transaction can be thought to start <BR>
+when control is transferred to &quot;executeQuery&quot; and the transaction ends just prior to return from this method.</P>
+
+<P><B>Writing Data</B><BR>
+Writes can be accomplished by two DAS APIs. First is calling the DAS &quot;execute()&quot; command against a command the <BR>
+will perform write operations and, in this case, the transaction boundaries are the same as read queries. That <BR>
+is the transaction life matches the life of the &quot;execute&quot; processing. If the method returns without exception <BR>
+then the application can assume that any changes were successfully committed to the database. If an exception is <BR>
+returned then the changes will have all been rolled back.</P>
+
+<P>The second API used by clients is the DAS applyChanges() method (see ChangeSummaryProcessing). Again, the <BR>
+boundaries of the transaction match the boundaries of the call to the method. The DAS will create a set of <BR>
+INSERT/UPDATE and DELETE statements to flush the graph changes to the database and all of these statements <BR>
+will be executed as part of a single transaction. If the method returns without exception then the application <BR>
+can assume that all changes were successfully committed to the database. If an exception is returned then the changes <BR>
+will have all been rolled back.</P>
+
+<P><B>Use</B></P>
+
+<P>This mode is useful for simple data operations, where there is no need of having group of SQL statements or group of DAS <BR>
+Commands in one transaction unit. At the maximum one applyChanges() call having multiple INSERT/UPDATE/DELETE executes <BR>
+under one transaction. Cases where multiple applyChanges() method calls or multiple executeQuery() method calls are <BR>
+required to be part of one transaction, this mode is not useful. In this mode, the database Connection can be internally <BR>
+obtained using DAS Config ConnectionInfo settings or database Connection can also be passed from the client to DAS instance. <BR>
+When DAS obtains database Connection internally, in Config ConnectionInfo, settings can either specify DataSource name or <BR>
+Database Driver related information. Typical examples - </P>
+<UL>
+ <LI>When using Tomcat based web app with DAS, Tomcat configured DataSource name is set in the DAS Config.</LI>
+ <LI>When using J2SE application client with DAS, Database Driver related information from DAS Config is used to form a database Connection.</LI>
+</UL>
+
+
+<P>When multiple SQL statements/DAS commands need to be part of one transaction and also when multiple DAS instances need to participate <BR>
+in one transaction, the other mode &quot;Externally managed transactions&quot; is useful.</P>
+
+<H3><A name="RDBDAS-TransactionControl-Externallymanagedtransactions"></A><A name="RDBDAS-TransactionControl-Externallymanagedtransactions"></A>Externally managed transactions</H3>
+
+<P>The RDB DAS provides a straightforward mechanism for working with external transactions. In this mode, DAS is configured to not issue <BR>
+commit/rollback. This behavior is needed to have the DAS participate in a larger transaction since some external party is responsible <BR>
+for these actions. </P>
+
+<P><B>Use</B></P>
+
+<P>The scope of transaction support is a blend of <B>Supports</B> and <B>Mandatory</B> transaction attributes in J2EE scenario. i.e. DAS will use the <BR>
+client's transaction if it is available. DAS does not throw exception if external client transaction is not available, but the end result <BR>
+without external transaction is unpredictable. So, when using DAS in this mode, client needs to ensure availability of external transaction <BR>
+encompassing required DAS/s commands. External transaction can be JDBC transaction or JTA transaction. </P>
+
+<P>When JDBC transaction, it is possible to group multiple Commands from single DAS instance in one transaction. Also nested transactions using <BR>
+multiple DAS instances can be carried out. AS JTA does not support nested transactions, if <B>nested transactions</B> is the requirement, JDBC <BR>
+Transactions should be used. For example:-</P>
+
+<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
+<PRE>Das1 = DAS.FACTORY.createDAS(jdbcconn1);
+Das2 = DAS.FACTORY.createDAS(jdbcconn2);
+
+try {
+ doSomeDAS1Stuff();
+ doSomeDAS2Stuff();
+ jdbcconn2.commit();
+ doSomeDAS1Stuff();
+ jdbcconn1.commit();
+} catch (AnyException ex) {
+ jdbcconn1.rollback();
+ jdbcconn2.rollback();
+}
+</PRE>
+</DIV></DIV>
+
+<P>When JTA transaction, multiple units like JMS, DAS1(derbydatabase1), DAS2(derbydatabase2/mysqldatabase2) can be part of single transaction. <BR>
+See example:-</P>
+
+<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
+<PRE>tx.begin();
+try {
+ doSomeJMSStuff();
+ doSomeDAS1Stuff();
+ doSomeDAS2Stuff();
+ tx.commit();
+} catch (AnyException ex) {
+ tx.rollback();
+}
+</PRE>
+</DIV></DIV>
+
+<P>In both the examples above, the DAS1 and DAS2 have been configured to not manage transactions since this is handled by the calling program.<BR>
+The DAS is set to behave this way by a piece of configuration (typically via a configuration xml file). The following config file snippet <BR>
+illustrates this setting:</P>
+
+<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
+<PRE>&lt;Config xsi:noNamespaceSchemaLocation=&quot;http:///org.apache.tuscany.das.rdb/config.xsd&quot;
+ xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
+
+ &lt;ConnectionInfo managedtx=&quot;false&quot;/&gt;
+
+&lt;/Config&gt;
+</PRE>
+</DIV></DIV>
+
+<P><B>Note</B> When using DAS with &quot;Externally managed transactions&quot;, it is required by the client to pass appropriate Connection object to DAS <BR>
+instance. There is no meaning to forming Connection internally in DAS using Config info, as such Connections will not be part of external <BR>
+Transaction Control.</P>
+
+<P><B>Methods Not Used in Externally managed transactions</B><BR>
+DAS does not invoke any method that might interfere with the transaction boundaries set by the Transaction Manager. The list of prohibited <BR>
+methods follows: </P>
+<UL>
+ <LI>The commit, setAutoCommit, and rollback methods of java.sql.Connection</LI>
+ <LI>The getUserTransaction method of javax.ejb.EJBContext</LI>
+ <LI>Any method of javax.transaction.UserTransaction</LI>
+</UL>
+
+
+<P><B>Note</B> DAS never allows AutoCommit(TRUE) for the Connection it is using and throws Exception if this mode is detected.</P>
+</TD></TR></TBODY></TABLE>
+ </DIV>
+ </DIV>
+ </DIV>
+ <!-- pageContent macro end -->
+
+ </TD>
+ </TR>
+ </TABLE>
+
+ <!-- footer macro -->
+ <SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+ </SCRIPT>
+ <SCRIPT type="text/javascript">
+ _uacct = "UA-1174707-5";
+ urchinTracker();
+ </SCRIPT>
+
+ <A href="http://www.statcounter.com/" target="_blank"><IMG src="http://c26.statcounter.com/counter.php?sc_project=2619156&java=0&security=94bd7e7d&invisible=0" alt="website stats" border="0"></A>
+
+ <DIV class="footer">
+ Copyright � 2003-2012, The Apache Software Foundation&nbsp;&nbsp;</BR>
+ Apache Tuscany and the Apache Tuscany project logo are trademarks of The Apache Software Foundation.
+ </DIV>
+ <!-- footer macro end -->
+
+ </BODY>
+</HTML>