There is an execute(Callable callable) method in the AbstractProcessApplication class that you can override to apply the tenant context to the running invocation thread.
Thanks, but I do not think so.
When is this method exactly called? If I set a breakpoint in running a unit test that will run some process, it is never called.
Also, looking at the arguments, I don’t have any information to determine the tenant id.
What I have build now:
I created a TenantCommandInterceptor that extends from the CommandInterceptor and is added as Post CommandInterceptor such that the Context is filled. As such, I can retrieve the Spring ProcessEngineConfig that contains the deployed tenant id, that is set during creation of the process engine. I remove the tenant id after the command did run. It’s a bit like how Spring wraps a command in a db transaction.
I am writing a unit test as we speak, but it seems to work fine.