How to configure MultiSchemaMultiTenant to use Spring Transactions

Hi there

tl;dr:how can we integrate Spring Boot Transactional support into flowable using the multi tenant setup?

We’re running a Spring Boot application using flowable. We have some controller methods annotated with @Transactional that perform some JPA tasks using Repositories and then initiate a flowable process, for example. This works ok ( see more details below ). On a new version of the application, we converted it to a multi-tenant application by using a MultiSchemaMultiTenantProcessEngineConfiguration for flowable, and using Hibernate’s support for “multi tenant with schema” ( implementing MultiTenantConnectionProvider, CurrentTenantIdentifierResolver ). This works ok except for the transactional support. In our controller methods, JPA actions are performed on one transaction, wrapped by the Transactional annotation, but flowable’s actions are performed autonomously using a MyBatis transaction.

In the previous version, I can see that there’s a SpringTransactionInterceptor that does the magic:

19:57:33.469 [http-nio-auto-1-exec-1] DEBUG o.f.c.e.i.interceptor.LogInterceptor.execute - --- starting StartProcessInstanceCmd --------------------------------------------------------
19:57:33.469 [http-nio-auto-1-exec-1] DEBUG o.f.c.s.SpringTransactionInterceptor.execute - Running command with propagation REQUIRED
19:57:33.470 [http-nio-auto-1-exec-1] DEBUG o.f.c.e.impl.agenda.AbstractAgenda.planOperation - Operation class org.flowable.engine.impl.interceptor.CommandInvoker$1 added to agenda
19:57:33.470 [http-nio-auto-1-exec-1] DEBUG o.f.e.i.interceptor.CommandInvoker.executeOperation - Executing operation class org.flowable.engine.impl.interceptor.CommandInvoker$1

but on the new multitenant version this is not present. I see another class performing the commits:

2024-04-26 00:06:58.833 DEBUG 4357 --- [mn-acquire-jobs] .c.s.StandaloneMybatisTransactionContext : firing event committing...
2024-04-26 00:06:58.833 DEBUG 4357 --- [mn-acquire-jobs] .c.s.StandaloneMybatisTransactionContext : committing the ibatis sql session...
2024-04-26 00:06:58.833 DEBUG 4357 --- [mn-acquire-jobs] .c.s.StandaloneMybatisTransactionContext : firing event committed...

I’ve tried to integrate SpringTransactionInterceptor in our implementation of SpringProcessEngineConfiguration, by doing something like:

    SpringTransactionInterceptor ci = new SpringTransactionInterceptor(platformTransactionManager);

but this is not working. It looks like we’re near there but this is giving some NPEs etc, and I can’t find any reference or examples.

So the question would be how can we integrate Spring Boot Transactional support into flowable using the multi tenant setup?