2 Replies Latest reply on Oct 22, 2018 2:25 AM by sewatech

    How to configure prepared-statement-cache-size in a XA DataSource with IJ Embedded ?

    sewatech

      Hi,

       

      I'm using IronJacamar embedded, with XA Datasource. I want to setup the prepared statement cache, but the configuration is not used.

       

      I'm configuring it just like a non-XA datasource :

       

      <?xml version="1.0" encoding="UTF-8"?>
      <datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:noNamespaceSchemaLocation="http://www.jboss.org/ironjacamar/schema/datasources_1_1.xsd">
          <xa-datasource jndi-name="java:/H2DS" pool-name="H2DS">
              <xa-datasource-property name="url">jdbc:h2:tcp://localhost/./db</xa-datasource-property>
              <!--<xa-datasource-property name="User">${archi.embedded.ds.User}</xa-datasource-property>-->
              <!--<xa-datasource-property name="Password">${archi.embedded.ds.Password}</xa-datasource-property>-->
              <!--<xa-datasource-property name="DriverType">org.h2.Driver</xa-datasource-property>-->
              <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
              <xa-pool>
                  <initial-pool-size>3</initial-pool-size>
                  <min-pool-size>5</min-pool-size>
                  <max-pool-size>7</max-pool-size>
                  <!--<is-same-rm>false</is-same-rm>-->
                  <no-tx-separate-pools />
              </xa-pool>
              <timeout>
                  <idle-timeout-minutes>11</idle-timeout-minutes>
              </timeout>
              <statement>
                  <prepared-statement-cache-size>13</prepared-statement-cache-size>
              </statement>
              <validation>
                  <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.novendor.JDBC4ValidConnectionChecker"/>
              </validation>
          </xa-datasource>
      </datasources>
      
      

       

      The <valid-connection-checker> is not used as well.

       

      Here is a small project that reproduce my problem : Alexis Hassler / sw-ijembed · GitLab , and I've added a CI job : Jobs · Alexis Hassler / sw-ijembed · GitLab .

       

      Is there a dedicated configuration for XA Datasource ?

       

      Thanks,

       

      Alexis

       

      (I've opened an issue : [JBJCA-1359] Missing configuration elements in the XA DataSources - JBoss Issue Tracker )

        • 1. Re: How to configure prepared-statement-cache-size in a XA DataSource with IJ Embedded ?
          virendra656

          Did you find any answer for the problem?

          • 2. Re: How to configure prepared-statement-cache-size in a XA DataSource with IJ Embedded ?
            sewatech

            Our latest workaround is to drop IronJacamar of our project, as I think that the Embedded part is no more an active feature.

            But I guess that it's not a useful answer if you've encountered the same problem.

             

            The problem come from the deployer which is incomplete.

            It can be worked around with a custom deployer like this :

             

            public class CustomDsXmlDeployer extends org.jboss.jca.deployers.fungal.DsXmlDeployer {
            
              @Override
              protected ManagedConnectionFactory createMcf(XaDataSource ds, String uniqueId, ClassLoader cl)
                  throws Exception {
                ManagedConnectionFactory mcf = super.createMcf(ds, uniqueId, cl);
                if (mcf instanceof BaseWrapperManagedConnectionFactory) {
                  BaseWrapperManagedConnectionFactory managedConnectionFactory = (BaseWrapperManagedConnectionFactory) mcf;
            
                  Statement statement = ds.getStatement();
                  Long preparedStatementsCacheSize = statement.getPreparedStatementsCacheSize();
                  if (preparedStatementsCacheSize != null) {
                    managedConnectionFactory.setPreparedStatementCacheSize(preparedStatementsCacheSize.intValue());
                  }
                  managedConnectionFactory.setSharePreparedStatements(statement.isSharePreparedStatements());
                  Statement.TrackStatementsEnum trackStatements = statement.getTrackStatements();
                  if (trackStatements != null) {
                    managedConnectionFactory.setTrackStatements(trackStatements.toString());
                  }
            
                  Validation validation = ds.getValidation();
                  if (validation != null) {
                    managedConnectionFactory.setCheckValidConnectionSQL(validation.getCheckValidConnectionSql());
                    Extension exceptionSorter = validation.getExceptionSorter();
                    Extension validConnectionChecker = validation.getValidConnectionChecker();
                    if (validConnectionChecker != null) {
                      managedConnectionFactory.setValidConnectionCheckerClassName(validConnectionChecker.getClassName());
                    }
                    Extension staleConnectionChecker = validation.getStaleConnectionChecker();
                    if (staleConnectionChecker != null) {
                      managedConnectionFactory.setStaleConnectionCheckerClassName(staleConnectionChecker.getClassName());
                    }
                    if (exceptionSorter != null) {
                      managedConnectionFactory.setExceptionSorterClassName(exceptionSorter.getClassName());
                    }
                  }
            
                  return managedConnectionFactory;
                }
                return mcf;
              }
            }