Configuring HikariCP with OpenEjb . ( need inputs)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Configuring HikariCP with OpenEjb . ( need inputs)

Kalyan
We are right now using DBCP datasource. But we would like to configure
HikariCP.

Could one of you please help validate if what we are doing below is the
correct way to get HikariCP Datasource works in container managed
transaction in embedded container.

Create a custom DataSourceCreator class for Hikari datasource and
set the “DataSourceCreator” property to the custom DataSourceCreator class.
Also should autoCommit be true when creating the HikariDataSource object in
the DataSourceCreator class?

public class HikariDataSourceCreator extends
org.apache.openejb.resource.jdbc.pool.PoolDataSourceCreator {
  @Override
  protected void doDestroy(CommonDataSource commonDataSource) throws
Throwable {
    ((HikariDataSource)commonDataSource).close();
  }
  @Override
  public DataSource pool(String name, DataSource ds, Properties properties)
{
    throw new UnsupportedOperationException("");
  }
  @Override
  public CommonDataSource pool(String name, String driver, Properties
properties) {
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setPoolName(name);
    hikariConfig.setJdbcUrl(properties.getProperty("JdbcUrl"));
    hikariConfig.setUsername(properties.getProperty("Username"));
    hikariConfig.setPassword(properties.getProperty("Password"));
   
hikariConfig.setMaximumPoolSize(Integer.parseInt(properties.getProperty("maxActive")));
   
hikariConfig.setMinimumIdle(Integer.parseInt(properties.getProperty("initialSize")));
    HikariDataSource dataSource = new HikariDataSource(hikariConfig);
    return dataSource;
  }
}


contextProperties.put(dataSourceName,"new://Resource?type=javax.sql.DataSource");
contextProperties.put(dataSourceName+".DataSourceCreator","org.superbiz.ejblookup.HikariDataSourceCreator");
contextProperties.put(dataSourceName+".JdbcDriver",
"oracle.jdbc.OracleDriver");
contextProperties.put(dataSourceName+".JtaManaged", "true”);

Please confirm





--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: Configuring HikariCP with OpenEjb . ( need inputs)

Kalyan
@Jon or @Richard !!
Could you please advice.

thanks
Kalyan



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Reply | Threaded
Open this post in threaded view
|

Re: Configuring HikariCP with OpenEjb . ( need inputs)

jgallimore
What you're after isn't entirely trivial, as the DataSourceFactory stuff
isn't as well aligned as it could be with the service-jar.xml code. We
should fix that and add HikariCP.

I'll map out some to dos over the next couple of days. This'll be awesome.

Jon

On Fri, 20 Dec 2019, 17:47 Kalyan, <[hidden email]> wrote:

> @Jon or @Richard !!
> Could you please advice.
>
> thanks
> Kalyan
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>
Reply | Threaded
Open this post in threaded view
|

Re: Configuring HikariCP with OpenEjb . ( need inputs)

Kalyan
Thank you Jon!

Regards
Kalyan



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html