3 Replies Latest reply on Jan 25, 2008 4:27 PM by Bob Roberts

    Pools and permits

    Bob Roberts Newbie

      For a <tx-connection-factory> with <xa-transaction/> but without <track-connection-by-tx/>, does obtaining a connection handle within an application component acquire an exclusive lock on the underlying managed connection?

      Is it possible to have multiple concurrent transactions all holding open handles to the same managed connection with transaction interleaving facilitating the context switching between them?

        • 1. Re: Pools and permits
          Adrian Brock Master

           

          "ydzsidemiik" wrote:
          For a <tx-connection-factory> with <xa-transaction/> but without <track-connection-by-tx/>, does obtaining a connection handle within an application component acquire an exclusive lock on the underlying managed connection?


          It does while you have the handle open. Although some other part of your application
          can open a new handle to the underlying connection in the same transaction,
          so it is not quite (but nearly) correct to say it is exclusive to the handle.


          Is it possible to have multiple concurrent transactions all holding open handles to the same managed connection with transaction interleaving facilitating the context switching between them?


          No. But the connection can be shared for the 2PC protocol.

          That is what interleaving means. The real connection (really its XAResource)
          can only be enlisted - XAResource.start() - in one transaction at once,
          but the prepare/commit() doesn't require the connection to be enlisted.

          e.g. Oracle XA doesn't allow true interleaving. You can't concurrently commit
          two "interleaved" transactions on the same connection (you can
          sequentially - but that isn't much use in a multi-threaded environment like JBoss :-)

          • 2. Re: Pools and permits
            Bob Roberts Newbie

            Thanks, this is what I suspected.

            I had a need to use concurrently a small number of managed connections, so I created another layer of indirection above the connection handle -- now that handle is used to create another handle, and then immediately closed. Use of the second handle can proceed in parallel against the same managed connection.

            Thanks for your time.

            • 3. Re: Pools and permits
              Bob Roberts Newbie

              In retrospect maybe this is wrong when considered against what you said.

              I admit I don't really know what I'm doing. What consequences could my approach have?