TenantWrappedTransactionManager does not return the tenant

Hello AxonIQ

We are working in a multi tenant application and we faced this situation:

There is an aggregate that receives a command and publish an event. The tenantId metadata is populated in event correctly and published to the right context as expected.
Then, we are listening that event in a saga that starts or cancel a scheduler.
I noticed that when we are cancelling a scheduler we got this log message:

No current tenant found. Canceling schedule token SimpleScheduleToken{tokenId=ā€˜33febd4b-24b0-4edd-a08a-7f33fd014f8eā€™} by searching in all tenants.

We debug and we noticed that axon is not able to get the tenant from the TenantWrappedTransactionManager (the getCurrentTenant returns null)

However, we can see that we are inside of a transaction:

TransactionSynchronizationManager.isActualTransactionActive() == true

And from the documentation, we were expecting that the TenantWrappedTransactionManager was able to resolve the tenant

While in transaction you may find out which tenant owns transaction by calling: TenantWrappedTransactionManager.getCurrentTenant()

Are we missing some configuration here?

Thanks in advance
Kind regards
Filipe Marques

Hi Filipe,

Can you maybe share some implementation code where you use TenantWrappedTransactionManager?

Hello Stefan,
We are not using the TenantWrappedTransactionManager directly:

@Autowired
private transient EventScheduler scheduler;

@SagaEventHandler(associationProperty = "key")
public void on(SchedulerCancelledEvent event)
{
scheduler.cancelSchedule(token);
}

and the EventScheduler used is the MultiTenantEventScheduler.

We can see that the TenantWrappedTransactionManager is being used in MultiTenantEventScheduler but the tenant is not being populated

Il try to reproduce it to see whats wrong

1 Like