Uploaded image for project: 'Agroal'
  1. Agroal
  2. AG-224

Add support for XA-properties from DataSourceProperties

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Done
    • Major
    • 2.3
    • None
    • api, infrastructure, pool, spring
    • None
    • False
    • None
    • False
    • 0
    • 0% 0%

    Description

      When using spring boot's XADataSourceAutoConfiguration, the XA-properties set in DataSourceProperties are being bound to the instance of the XADataSource, using properties binding. XA-properties in DataSourceProperties are arbitrary key-value-pairs that can be used with spring boot's property binding. While a java.sql.Driver's connect()-method has the option to pass in arbitrary properties, the XADataSource does not support this and so the properties/configuration need to be set on the instance of the used XADataSource.

      At this point AgroalDataSourceConfiguration is not using DataSourceProperties's XA-properties, which means that no additional configuration can be done for XADataSources when using the AutoConfiguration.

      The easy solution would be to set jdbcProperties with the XA-properties. The jdbcProperties will be used in agroal's ConnectionFactory and depending on the factoryMode they are being passed to the Driver#connect(String, Properties) method or they are being used to inject into the instance of the XADataSource of DataSource. But Properties being passed to the Driver and Properties that need to be injected into the instance of the (XA)DataSource are not the same! While they might be similar and match the inner workings of PropertyInjector/Binder, they are not the same. While spring boot's Binder and agroal's PropertyInjector are probably built to match this, there is no way of being sure if the properties that a driver's connect() accepts match the way the Binder/PropertyInjector binds/injects the same properties to/into the concrete instance of the XADataSource. So whether or not the XA-properties can be put into the jdbcProperties depends on what they are being used for. This depends on the factoryMode, which is unknown during creation of the AgroalDatasource-bean and also an inner working of the ConnectionFactory.

      So it seems like either the AutoConfiguration needs to smarter or more information about the inner workings of the AgroalDatasource need to be exposed. Or there needs to be a separate property (xaProperties) in the AgroalConnectionFactoryConfiguration. It seems like a separate property is the way to go in order to distinguish the use of jdbcProperties from xaProperties. The former is to be passed into the Driver#connect(String, Properties) method and the latter is being bound to/injected into the instance of the XADataSource.

      Attachments

        Activity

          People

            lbarreiro-1 Luis Barreiro
            kimdlanor Ronald Mik
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: