4 Replies Latest reply on Jan 22, 2008 4:45 PM by shelly.mcgowan

    Connection Sharing

    shelly.mcgowan

      I've been looking at an issue which is consistent with the LocalTransaction scenario described in the Connector Specification (7.10.3). In this scenario, two EJBs get a connection to the same resource manager in asingle transaction.
      EJB ==> Stateful Bean-Managed Bean using JTA to demarcate TX
      EJB1 ==> Stateful Container-Managed Bean with TX_REQUIRED attribute for business methods
      EJB2 ==> Stateful Container-Managed Bean with TX_REQUIRE attribute for business methods

      From EJB, the first ut.begin is called.
      Method calls in EJB1 are performed to get a connection and delete any
      rows found in the table in preparation for the test.
      From EJB, ut.commit is called.

      From EJB, a second ut.begin call is made.

      a method call to EJB1.insert() is called where a connection is made to insert the row. From within this same method, a call to EJB2 dbConnect method is made. In this dbConnect method, another call to ds.getConnection() is performed. When ds.getConnection() is called, a new ManagedConnection is created resulting in two InUse connections and an attempt enlist the TX fails as multiple last resources is disallowed. The TX is aborted and marked for rollback. The resources are marked Shareable in the resource-ref elements of each EJB. Therefore, I expected that the connection handle for the same ManagedConnection instance used for handling the connection request for EJB1 would be provided by the container thus retaining the association of the local transaction context between EJB1 and EJ2 method calls.Can you confirm that should be the case with the latest version of JBoss AS 5.0.0.Beta3/4?

        • 1. Re: Connection Sharing
          vickyk

           

          "smcgowan@redhat.com" wrote:
          Can you confirm that should be the case with the latest version of JBoss AS 5.0.0.Beta3/4?

          If you see the JCA specs you would notice this
          The container returns a connection handle using the same ManagedConnection
          instance that was used for handling the connection request from A.

          So for the scenario described in 7.10.3 the connection handles are shared and not the physical connections(ManagedConnection)
          I see this happening from the code also .
          The above explaination would answer why you have 2 inUseConnectionCount.
          I am not sure if I did answer your question here , Did I answer it ?

          • 2. Re: Connection Sharing
            shelly.mcgowan

            I can resolve this issue by setting the property:

            in jbossjta-properties.xml but I don't think that is the solution. When running this test with AS 4.2, calling EJB2's business method to get another connection shows that we are tracking by Tx; i.e.,
            TRACE [org.jboss.resource.connectionmanager.TxConnectionManager]
            getManagedConnection trackByTx=true tx=TransactionImple < ac, BasicAction: -53efacde:e2c1:476000d6:51 status: ActionStatus.RUNNING >

            and we get the connectionfrom the pool trackedByTx:
            Got connection from pool tracked by transaction org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@1d63c55
            thus;
            Using connection from pool tracked by transaction org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@1d63c55
            handles=0
            [InUse/Available/Max]: [1/19/20]

            With the old xslt deployer, these mbean attributes were set :
            true
            true

            With AS5, calling ds2.getConnection() in EJB2, trackByTx is false;
            TRACE [org.jboss.resource.connectionmanager.TxConnectionManager:350]
            getManagedConnection trackByTx=false tx=null subject=null

            supplying new ManagedConnection: org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@17dbcd4
            Got connection from pool org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@17dbcd4
            [InUse/Available/Max]: [2/8/10]

            With the new deployment
            TRACE [org.jboss.resource.deployment.ResourceAdapterObjectModelFactory:486] transaction support setValue: nuri=http://java.sun.com/xml/ns/j2ee localName=transaction-support value=LocalTransaction
            was added for the ConnectorMetaData but I don't see TrackStatements.

            • 3. Re: Connection Sharing
              shelly.mcgowan

              The property,

              that is.

              • 4. Re: Connection Sharing
                shelly.mcgowan

                com.arjuna.ats.jta.allowMultipleLastResources=true