4 Replies Latest reply on Nov 24, 2004 4:26 PM by kalyan120

    Connection creation at the startup

      Hi,

      I'm accessing a relational database using JBoss JCA. In the *-ds.xml I have mentioned the min-pool-size to be 5. But I notice that these connections not are created until a query is executed for the first time (that requires a connection from this connection pool).

      I have a situation where this will be a problem. I have to create connection pools at the server startup, and to create each connection in the connection pool, it takes about 3 minutes (worst case). This is because, I need to create some temp tables in that connection. In this scenario, I cannot make the user wait for 3 minutes when the user accesses the connection for the first time.

      To circumvent this, I can write a simple mbean that's deployed just after the *-ds.xml, that accesses a connection from the connection pool. This way I can be sure that the minimum no. of connections are created at the server startup.

      But, can I do it by simple configuration, where I can turn off this feature?

      Also, why is a connection created only when a connection is requested for the first time?

      Thanks,
      Kalyan.

        • 1. Re: Connection creation at the startup

          This is an old FAQ, it has been discussed quite a few times before.

          I would suggest using search, but you'll have to filter out all the posts similar to this
          one where I couldn't be bothered to answer it, again...

          I will accept a patch that allows a

          <prefill/>
          

          in the -ds.xml, but only if pooling Criteria is ByNothing and
          <no-tx-separate-pools/>
          

          has not been specified.

          Without that constrain, it is impossible/undesirable for the pool(s!) to prefill.
          Although, you could imagine a hack where it also did it for the ByContainer
          pooling criteria, if it knew the login module was ConfiguredIdentity or a subclass thereof.

          • 2. Re: Connection creation at the startup

            Thanks for the reply Adrian

            I have searched the forums with the words "minimum connection" , "min-pool-size", "pool filler" in various combinations, but couldn't get to see many posts that have any answer to my question. So, I'm resorting back to you, if you can provide me of any links, or search phrases. Moreover, this question is not part of the JCA FAQ.

            Your reply also doesn't tell me if there is a way to do that or not. Please let me know if there is a provision to make use of pool filler to create the connections at the startup.

            Thanks,
            Kalyan.

            • 3. Re: Connection creation at the startup

              No there is currently no way to do it.

              The reason is because in general extra information is required before connections
              can be constructed. This is the ManagedConnectionFactory's ConnectionRequestInfo,
              whether there is a transaction and in some cases what is the user/password
              of the EJB/servlet request.
              This information is only provided when the application makes the first request.

              e.g. For JMS you cannot know whether the pool should be filled Queue or Topic
              connections.
              e.g.2 For Oracle XA you need to know whether the connections will be used
              inside or outside a transaction the <no-tx-separate-pool/> workaround.

              The criteria I listed above are the special cases where it could in principle do
              a prefill because it has enough information.
              BUT, it does not do this in the current implementation.

              Additionally, with the default configuration, any prefilled connections would be closed
              anyway after 15 minutes of non-use.

              All the pooling parameters are listed here:
              http://www.jboss.org/wiki/Wiki.jsp?page=ConfigJCACommon

              • 4. Re: Connection creation at the startup

                Thanks a lot Adrian

                Regards,
                Kalyan.