9 Replies Latest reply on Nov 11, 2011 10:03 AM by jesper.pedersen

    Calling matchManagedConnections and getInvalidConnections

    pjuza

      Hello,

      I generated resource adapter by code generator (1.5 JCA spec, no transactions, no datasource, outbound) and I'm not able to call generated matchManagedConnections() and manually added ValidatingManagedConnectionFactory.getInvalidConnections() methods for checking valid connections?


       

      Thank you in advance,

      PETER

        • 1. Re: Calling matchManagedConnections and getInvalidConnections
          jesper.pedersen

          The JCA container calls matchManagedConnections() in order to verify if a ManagedConnection can be reused - see http://docs.jboss.org/ironjacamar/userguide/1.1/en-US/html/samples.html#sample_helloworld_mcf. In most cases you would use the Subject and/or CRI to verify a match.

           

          The ValidatingManagedConnectionFactory interface can be implemented in order to help the JCA container to clean up unneeded managed connections.

           

          HTH

          • 2. Re: Calling matchManagedConnections and getInvalidConnections
            pjuza

            Thank you for your respond but I have a problem that these methods are not called by JCA container.

            I implemented both of them for better connection reuse but these methods are never called and I don't know why?

             

            PETER

            • 3. Re: Calling matchManagedConnections and getInvalidConnections
              jesper.pedersen

              Please, go through the HelloWorld example first.

              • 4. Re: Calling matchManagedConnections and getInvalidConnections
                pjuza

                I have already went through example several times, I will try it again - please, could you focus me where could be the problem?

                 

                PETER

                • 5. Re: Calling matchManagedConnections and getInvalidConnections
                  jesper.pedersen

                  It could be a ton of different things - have you implemented ConnectionEventListener interaction correct, have you a correct pool setup, are the background validation parameters set, and so on.

                  • 6. Re: Calling matchManagedConnections and getInvalidConnections
                    pjuza

                    I generated RA skeleton with code generator (like follows) and I would expect that everything was corretly generated:

                     

                    marti-pc:codegenerator pjuza$ sh ./codegenerator.sh

                    Profile version (1.6/1.5/1.0) [1.6]: 1.5

                    Type (O/Outbound/I/Inbound/B/Bidirectional) [O]:

                    Package name: com.cleverlance.smartclient.ra.httpclient

                    Transaction support (N/NoTransaction/L/LocalTransaction/X/XATransaction) [N]:

                    Support reauthentication (Y/Yes/N/No) [N]:

                    Include a ResourceAdapter (Y/Yes/N/No) [Y]:

                    Resource adapter class name [AcmeResourceAdapter]: HttpClientResourceAdapterImpl

                    Resource adapter config properties [enter to quit]:

                        Name:

                    Managed connection factory class name [AcmeManagedConnectionFactory]: HttpClientResourceAdapterImpl

                    Managed connection factory config properties [enter to quit]:

                        Name:

                    Use ResourceAdapterAssociation (Y/Yes/N/No) [Y]:

                    Managed connection class name [AcmeManagedConnection]: HttpClientManagedConnectionImpl

                    Use CCI (Y/Yes/N/No) [N]:

                    Connection factory interface class name [AcmeConnectionFactory]: HttpClientRaConnectionFactory

                    Connection factory implementation class name [AcmeConnectionFactoryImpl]: HttpClientRaConnectionFactoryImpl

                    Connection interface class name [AcmeConnection]: ManagedClientConnection

                    Connection implementation class name [AcmeConnectionImpl]: ManagedClientConnectionImpl

                    Add methods to connection interface (Y/Yes/N/No) [N]:

                    Additional managed connection factory (Y/Yes/N/No) [N]:

                    Include an admin object (Y/Yes/N/No) [N]:

                    Generate a MBean class (Y/Yes/N/No) [Y]:

                    Build environment [A/Ant/I/Ant+Ivy/M/Maven] [A]: M

                    Code generated

                     

                    I have been trying to change settings in ironjacamar.xml but without positive results. I doubt if matching connection is possible for non-datasource connections? And if it's true then it is specific for ironjacamar only or is it general JCA contract?

                    • 7. Re: Calling matchManagedConnections and getInvalidConnections
                      pjuza

                      I will reply to myself - I read JCA specification and I found:

                       

                      "Connection Matching Contract

                       

                      The application server invokes the ManagedConnectionFactory.matchManagedConnections method (implemented by a resource adapter) to find a matching ManagedConnection for servicing a connection request. The application server passes a candidate set of ManagedConnection instances to the matchManagedConnections method.

                       

                      The application server should use the connection matching contract for ManagedConnection instances that have no existing connection handles. A candidate set passed to the matchManagedConnections method should not have any ManagedConnection instances with existing connection handles."

                       

                      Now ManagedConnectionFactory.matchManagedConnections is called.

                      • 8. Re: Calling matchManagedConnections and getInvalidConnections
                        pjuza

                        I found the following about ResourceAdapterAssociation.getInvalidConnections:

                         

                        "This optional functionality may be used by the application server to prune invalid ManagedConnection objects from its connection pool periodically."

                         

                        Is this interface/functionality supported by IronJacamar?

                        • 9. Re: Calling matchManagedConnections and getInvalidConnections
                          jesper.pedersen

                          Yes, enable background validation and set the frequency.