Re: OpenJPA pool with DBCP
Wojtek <[email protected]>
| Newsgroups | gmane.comp.jakarta.james.user |
|---|---|
| Message-ID | <[email protected]> |
On 05/06/2023 21:56, Benoit TELLIER wrote:
> On 05/06/2023 23: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 so.
>
> I would suggest formally testing it with gatling:
> https://github.com/apache/james-project/blob/master/server/apps/distributed-app/docs/modules/ROOT/pages/benchmark/james-benchmark.adoc
Oh, thanks for the link. I'll do that.
>> 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)
> +1
>>
>> (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.
> Nice catch. Fix welcome.
https://github.com/apache/james-project/pull/1580
Wojtek