Re: OpenJPA pool with DBCP
Wojtek <[email protected]>
| Newsgroups | gmane.comp.jakarta.james.user |
|---|---|
| Message-ID | <[email protected]> |
On 05/06/2023 12:48, Wojtek wrote:
>> For instance https://github.com/apache/james-project/pull/1579 requires to allow JPA in a
>> multithread enviroment by setting -Dopenjpa.Multithreaded=true (required for the inter-operability
>> with reactor...) cf
>> https://github.com/chibenwa/james-project/blob/46168bb2f74d9186f10c101a7b6df3f5468927a5/server/apps/jpa-app/sample-configuration/jvm.properties#L53
>
> I actually included that configuration option but from my tests it seemed it didn't have any effect.
> After adding `properties.put("openjpa.Multithreaded", "true");` in
> org.apache.james.modules.data.JPAEntityManagerModule#provideEntityManagerFactory fixed the issue.
>
>
> Though, with that config and exceptions gone I only got to 5 database connections (default max is 8)
> - most likely inserts were not concurrent enough to trigger more connections?
>
>
> I think all openjpa.*/datasource.* options from `james-database.properties` should be passed to
> OpenJPA/DBCP. This way one would get complete freedom in configuring/tweaking those libraries
> configs (https://openjpa.apache.org/builds/3.2.2/apache-openjpa/docs/manual.html and
> https://commons.apache.org/proper/commons-dbcp/configuration.html)
>
> (btw. it seems that TestOnBorrow option has a bug as it inserts `TestOnBorrow=Optional[…]` and
> should use `jpaConfiguration.isTestOnBorrow().ifPresent(testOnBorrow ->
> connectionFactoryProperties.add("TestOnBorrow=" + testOnBorrow));` like other config options.
>
> Wojtek
I created a PR which should addres above comments: https://github.com/apache/james-project/pull/1580
Wojtek