2 Replies Latest reply on May 12, 2005 6:26 PM by adrian.brock

    ManagedConnection shared by multiple Connections

    camueller

      We are developing a J2EE application where multiple clients (EJBs) can connect simultanously to a device connected via single TCP-style connection. The communication protocol _does_ support concurrent communication of clients over this single connection.
      Using JCA (NoTransaction, Managed) we decided to manage the TCP connection inside a ManagedConnection. EJB clients would retrieve a Connection which possibly uses the same ManagedConnection as another EJB client if both have to communicate with the same device. According to the spec, chapter 6.5.4.2, multiple Connections sharing a ManagedConnection should be supported.
      However we experienced the following:
      If one EJB requests an Connection a corresponding ManagedConnection is created and the EJB client then executes an Interaction. While the interaction is running, if another EJB client requests a Connection with the same ConnectionSpec, the JBoss ConnectionManager always calls createManagedConnection() on the ManagedConnectionFactory. Since the ManagedConnection represents the communication channel to the device we cannot create a second one. Instead we want to create a new Connection but for the already existing ManagedConnection.
      How could we accomplish this?

      Axel

        • 1. Re: ManagedConnection shared by multiple Connections

           

          "camueller" wrote:
          According to the spec, chapter 6.5.4.2, multiple Connections sharing a ManagedConnection should be supported.


          Yes, in the same transaction for example, the connection handles share the same
          real managed connection:

          UserTransaction ut = ...
          ut.begin();
          Connection c1 = connectionFactory.getConnection();
          Connection c2 = connectionFactory.getConnection();
          


          Absent a transaction how is the pooling to know that the connection can be shared?

          • 2. Re: ManagedConnection shared by multiple Connections

            What you really want is a custom pool which has a pooling strategy of
            "Don't Pool - Share".

            The only mechanism in JBoss to use your own custom pool is to deploy using the MBeans
            directly rather than using the -ds.xml (see previous posts for examples).
            But the MBean api is not guaranteed to be stable across releases.