Class TenantScope
Background threads (the outbox poller, Quartz, file watch, work-queue runners) have no
request to take the tenant from, and code they call may change the ContextContainer:
a nested Chenile call, for example. call(String, Supplier) therefore does two things for the duration of
the work: it sets the tenant in the ContextContainer, and it pins the tenant on
the thread. A tenant-routing DataSource (multi-datasource-utils'
TenantRoutingDataSource) routes by the pinned tenant first, so a REQUIRES_NEW
transaction opened deep inside the work still reaches the right database. Both are restored
afterwards, also when the work fails.
Without multi-datasource-utils there is one database; pinning is then harmless and only the
ContextContainer tenant matters. A blank tenant runs the work unchanged.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
pinned
-
-
Constructor Details
-
TenantScope
public TenantScope()
-
-
Method Details
-
pinnedTenant
The tenant pinned on this thread, or null. -
run
-
call
-
CHENILE