User: hiram
Date: 01/01/08 13:47:25
Modified: src/java/org/spydermq SpyXAResourceManager.java
SpySession.java
Log:
XAResourceManager fix. endTX() is called now before commitTX()
(The way a TransactionManager would do it)
Revision Changes Path
1.4 +12 -8 spyderMQ/src/java/org/spydermq/SpyXAResourceManager.java
Index: SpyXAResourceManager.java
===================================================================
RCS file:
/products/cvs/ejboss/spyderMQ/src/java/org/spydermq/SpyXAResourceManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SpyXAResourceManager.java 2000/12/26 04:15:51 1.3
+++ SpyXAResourceManager.java 2001/01/08 21:47:24 1.4
@@ -19,7 +19,7 @@
*
* @author Hiram Chirino ([EMAIL PROTECTED])
*
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class SpyXAResourceManager implements java.io.Serializable {
@@ -33,10 +33,10 @@
//Valid tx states:
private static final byte TX_OPEN = 0;
- private static final byte TX_SUSPENDED = 1;
- private static final byte TX_PREPARED = 2;
- private static final byte TX_COMMITED = 3;
- private static final byte TX_ROLLEDBACK = 4;
+ private static final byte TX_SUSPENDED = 2;
+ private static final byte TX_PREPARED = 3;
+ private static final byte TX_COMMITED = 4;
+ private static final byte TX_ROLLEDBACK = 5;
//////////////////////////////////////////////////////////////////
// Helper Inner classes
@@ -80,9 +80,10 @@
}
public void commit(Object xid, boolean onePhase) throws XAException,
JMSException {
- TXState state = (TXState) transactions.get(xid);
+ TXState state = (TXState) transactions.remove(xid);
if (state == null)
throw new XAException(XAException.XAER_NOTA);
+
if (onePhase) {
TransactionRequest transaction = new TransactionRequest();
transaction.requestType = transaction.ONE_PHASE_COMMIT_REQUEST;
@@ -110,9 +111,10 @@
}
public void endTx(Object xid, boolean success) throws XAException {
- Object state = transactions.remove(xid);
+ TXState state = (TXState)transactions.get(xid);
if (state == null)
throw new XAException(XAException.XAER_NOTA);
+ state.txState = TX_ENDED;
}
public Object joinTx(Xid xid) throws XAException {
@@ -150,7 +152,7 @@
}
public void rollback(Object xid) throws XAException, JMSException {
- TXState state = (TXState) transactions.get(xid);
+ TXState state = (TXState) transactions.remove(xid);
if (state == null)
throw new XAException(XAException.XAER_NOTA);
if (state.txState != TX_PREPARED) {
@@ -194,4 +196,6 @@
throw new XAException(XAException.XAER_NOTA);
return xid;
}
+
+ private static final byte TX_ENDED = 1;
}
1.24 +3 -7 spyderMQ/src/java/org/spydermq/SpySession.java
Index: SpySession.java
===================================================================
RCS file: /products/cvs/ejboss/spyderMQ/src/java/org/spydermq/SpySession.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- SpySession.java 2000/12/29 05:39:50 1.23
+++ SpySession.java 2001/01/08 21:47:24 1.24
@@ -34,7 +34,7 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author Hiram Chirino ([EMAIL PROTECTED])
*
- * @version $Revision: 1.23 $
+ * @version $Revision: 1.24 $
*/
abstract public class SpySession
implements Runnable, Session, XASession
@@ -293,14 +293,12 @@
// commit transaction with onePhase commit
try {
+
connection.spyXAResourceManager.endTx(currentTransactionId, true);
connection.spyXAResourceManager.commit(currentTransactionId, true);
} catch ( javax.transaction.xa.XAException e ) {
connection.failureHandler(e,"Could not commit");
} finally {
try {
-
connection.spyXAResourceManager.endTx(currentTransactionId, true);
- } catch ( Exception ignore ) {}
- try {
currentTransactionId =
connection.spyXAResourceManager.startTx();
} catch ( Exception ignore ) {}
}
@@ -323,13 +321,11 @@
// rollback transaction
try {
+
connection.spyXAResourceManager.endTx(currentTransactionId, true);
connection.spyXAResourceManager.rollback(currentTransactionId);
} catch ( javax.transaction.xa.XAException e ) {
connection.failureHandler(e,"Could not commit");
} finally {
- try {
-
connection.spyXAResourceManager.endTx(currentTransactionId, true);
- } catch ( Exception ignore ) {}
try {
currentTransactionId =
connection.spyXAResourceManager.startTx();
} catch ( Exception ignore ) {}