[jboss-cvs] JBossAS SVN: r83633 - branches/Branch_5_0/connector/src/main/org/jboss/resource/adapter/jms/inflow.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 29 16:21:11 EST 2009
Author: jhowell at redhat.com
Date: 2009-01-29 16:21:11 -0500 (Thu, 29 Jan 2009)
New Revision: 83633
Modified:
branches/Branch_5_0/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSession.java
Log:
[JBAS-6431] - Fix [JBAS-6343] to allow transacted sessions only.
Modified: branches/Branch_5_0/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSession.java
===================================================================
--- branches/Branch_5_0/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSession.java 2009-01-29 20:18:33 UTC (rev 83632)
+++ branches/Branch_5_0/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSession.java 2009-01-29 21:21:11 UTC (rev 83633)
@@ -331,16 +331,21 @@
public LocalDemarcationStrategy() throws Throwable
{
- final int timeout = pool.getActivation().getActivationSpec().getTransactionTimeout();
+ final int timeout = pool.getActivation().getActivationSpec().getTransactionTimeout();
+ final boolean sessionTransacted = pool.getActivation().getActivationSpec().isSessionTransacted();
- if (timeout > 0)
+ if(!sessionTransacted)
{
- log.trace("Setting transactionTimeout for JMSSessionPool to " + timeout);
- tm.setTransactionTimeout(timeout);
+
+ if (timeout > 0)
+ {
+ log.trace("Setting transactionTimeout for JMSSessionPool to " + timeout);
+ tm.setTransactionTimeout(timeout);
+ }
+ //we need to begin a tx so that we can get a handle to the tx in end. In end we will roll back the session.
+ tm.begin();
+ trans=tm.getTransaction();
}
- //we need to begin a tx so that we can get a handle to the tx in end. In end we will roll back the session.
- tm.begin();
- trans=tm.getTransaction();
}
public void error()
@@ -379,63 +384,92 @@
}
public void end()
- {
- try
- {
+ {
+ final JmsActivationSpec spec = pool.getActivation()
+ .getActivationSpec();
- // Use the TM to commit the Tx (assert the correct association)
- Transaction currentTx = tm.getTransaction();
- if (trans.equals(currentTx) == false)
- throw new IllegalStateException("Wrong tx association: expected " + trans + " was " + currentTx);
+ if (spec.isSessionTransacted())
+ {
+ if (session != null)
+ {
+ try
+ {
+ session.commit();
+ } catch (JMSException e)
+ {
+ log.error("Failed to commit session transaction", e);
+ }
+ }
+ }
+ else
+ {
- // Marked rollback
- if (trans.getStatus() == Status.STATUS_MARKED_ROLLBACK)
- {
- log.trace(JmsServerSession.this + " rolling Transacted session back due to Transaction Rollback");
- //call to error, if we are rolled back
- error();
- }
+ try
+ {
- else if (trans.getStatus() == Status.STATUS_ACTIVE)
- {
- // Commit tx
- // This will happen if
- // a) everything goes well
- // b) app. exception was thrown
- if (trace)
- log.trace(JmsServerSession.this + " commiting the JMS transaction tx=" + trans);
- tm.commit();
+ // Use the TM to commit the Tx (assert the correct
+ // association)
+ Transaction currentTx = tm.getTransaction();
+ if (trans.equals(currentTx) == false)
+ throw new IllegalStateException(
+ "Wrong tx association: expected " + trans
+ + " was " + currentTx);
- // NO XASession? then manually commit. This is not so good but
- // it's the best we can do if we have no XASession.
- if (xaSession == null && pool.getActivation().isDeliveryTransacted())
- {
- log.trace(JmsServerSession.this + " commiting Transacted session");
- session.commit();
- }
+ // Marked rollback
+ if (trans.getStatus() == Status.STATUS_MARKED_ROLLBACK)
+ {
+ log
+ .trace(JmsServerSession.this
+ + " rolling Transacted session back due to Transaction Rollback");
+ // call to error, if we are rolled back
+ error();
+ }
- }
- else
- {
- tm.suspend();
+ else if (trans.getStatus() == Status.STATUS_ACTIVE)
+ {
+ // Commit tx
+ // This will happen if
+ // a) everything goes well
+ // b) app. exception was thrown
+ if (trace)
+ log.trace(JmsServerSession.this
+ + " commiting the JMS transaction tx="
+ + trans);
+ tm.commit();
- if (xaSession == null && pool.getActivation().isDeliveryTransacted())
- {
- session.rollback();
- }
+ // NO XASession? then manually commit. This is not so
+ // good but
+ // it's the best we can do if we have no XASession.
+ if (xaSession == null
+ && pool.getActivation().isDeliveryTransacted())
+ {
+ log.trace(JmsServerSession.this
+ + " commiting Transacted session");
+ session.commit();
+ }
- }
+ } else
+ {
+ tm.suspend();
- }
- catch (Throwable t)
- {
- log.error(JmsServerSession.this + " failed to commit/rollback", t);
- }
+ if (xaSession == null
+ && pool.getActivation().isDeliveryTransacted())
+ {
+ session.rollback();
+ }
- }
+ }
- }
+ } catch (Throwable t)
+ {
+ log.error(JmsServerSession.this
+ + " failed to commit/rollback", t);
+ }
+ }
+ }
+ }
+
private class XATransactionDemarcationStrategy implements
TransactionDemarcationStrategy
{
More information about the jboss-cvs-commits
mailing list