Interface TenantResolver
- All Known Implementing Classes:
MetadataBasedTenantResolver
public interface TenantResolver
Resolves the target tenant of a given
Message, and attaches a tenant to a Message in the
inverse direction.
A message dispatched from within a handler generally does not name its own tenant: the tenant is only
known through the ProcessingContext of the message
being handled. attachTenant(Message, TenantDescriptor) is what makes that tenant survive the
message being dispatched elsewhere, for example across a distributed command or query bus that carries
the message to another process and back. A resolver that only resolves, and never attaches, silently
drops the tenant on every such dispatch, with no signal that anything is missing until a receiving
component fails to resolve a tenant it should have had.
- Since:
- 4.6.0
- Author:
- Stefan Dragisic, Jan Galinski, Jakob Hatzl
-
Method Summary
Modifier and TypeMethodDescriptionattachTenant(Message message, TenantDescriptor tenant) Returns a copy of the givenmessagecarrying the giventenant, the inverse ofresolveTenant(Message, Collection): where that method determines the tenant a message belongs to, this one makes that determination survive the message being dispatched elsewhere.default TenantDescriptorresolveTenant(Message message) ReturnsTenantDescriptorfor the givenmessage.resolveTenant(Message message, Collection<TenantDescriptor> tenants) ReturnsTenantDescriptorfor the givenmessage.
-
Method Details
-
resolveTenant
TenantDescriptor resolveTenant(Message message, Collection<TenantDescriptor> tenants) throws TenantNotResolvedException ReturnsTenantDescriptorfor the givenmessage.- Parameters:
message- theMessageimplementation to resolve the target tenant fortenants- the collection of tenants to resolve the target tenant from- Returns:
- the resolved
TenantDescriptorbased on the givenmessage - Throws:
TenantNotResolvedException- if no tenant could be resolved
-
resolveTenant
ReturnsTenantDescriptorfor the givenmessage. This method is a convenience method that callsresolveTenant(Message, Collection)with an empty collection of tenants.- Parameters:
message- theMessageimplementation to resolve the target tenant for- Returns:
- the resolved
TenantDescriptorbased on the givenmessage - Throws:
TenantNotResolvedException- if no tenant could be resolved- See Also:
-
attachTenant
Returns a copy of the givenmessagecarrying the giventenant, the inverse ofresolveTenant(Message, Collection): where that method determines the tenant a message belongs to, this one makes that determination survive the message being dispatched elsewhere.- Parameters:
message- the message to attach the giventenanttotenant- the tenant to attach to the givenmessage- Returns:
- a copy of the given
messagecarrying the giventenant
-