Class AttachTenantDescriptorDispatchInterceptor
java.lang.Object
io.axoniq.framework.messaging.multitenancy.api.AttachTenantDescriptorDispatchInterceptor
- All Implemented Interfaces:
MessageDispatchInterceptor<Message>
@Internal
public class AttachTenantDescriptorDispatchInterceptor
extends Object
implements MessageDispatchInterceptor<Message>
A
MessageDispatchInterceptor that attaches the tenant of the dispatching ProcessingContext onto a
dispatched command or query, so it stays attributable to that tenant once it crosses a distributed command or
query bus and arrives in a fresh ProcessingContext on the receiving side.
The tenant is decided by the shared TenantRouter, the same way every other tenant-routing component
decides it. When the dispatching context carries no tenant, for example because the message is dispatched
outside of any handler, this interceptor does nothing.
The dispatch-side counterpart of RegisterTenantDescriptorHandlerInterceptor: that interceptor registers the
tenant of a handled message onto the ProcessingContext; this one attaches that same tenant onto a message
dispatched from within that handling, so a receiving component can resolve it without the message having named a
tenant of its own.
- Since:
- 5.3.0
- Author:
- Jakob Hatzl
-
Constructor Summary
ConstructorsConstructorDescriptionAttachTenantDescriptorDispatchInterceptor(TenantRouter tenantRouter) Constructs anAttachTenantDescriptorDispatchInterceptorattaching the tenant decided by the giventenantRouteronto a dispatched command or query. -
Method Summary
Modifier and TypeMethodDescriptioninterceptOnDispatch(Message message, @Nullable ProcessingContext context, MessageDispatchInterceptorChain<Message> interceptorChain) Intercepts a givenmessageon dispatching.
-
Constructor Details
-
AttachTenantDescriptorDispatchInterceptor
Constructs anAttachTenantDescriptorDispatchInterceptorattaching the tenant decided by the giventenantRouteronto a dispatched command or query.- Parameters:
tenantRouter- the router deciding which tenant the dispatchingProcessingContextbelongs to
-
-
Method Details
-
interceptOnDispatch
public MessageStream<?> interceptOnDispatch(Message message, @Nullable ProcessingContext context, MessageDispatchInterceptorChain<Message> interceptorChain) Description copied from interface:MessageDispatchInterceptorIntercepts a givenmessageon dispatching. The implementer of this method might want to intercept the message before passing it to the chain (effectively before callingMessageDispatchInterceptorChain.proceed(Message, ProcessingContext)) or after the chain (by mapping the resulting message by callingMessageStream.mapMessage(Function)).- Specified by:
interceptOnDispatchin interfaceMessageDispatchInterceptor<Message>- Parameters:
message- The message to intercept on dispatching.context- The active processing context, if any. Can be used to (e.g.) validate correlation data.interceptorChain- The interceptor chain to signal that processing is finished and further interceptors should be called.- Returns:
- The resulting message stream from
MessageDispatchInterceptorChain.proceed(Message, ProcessingContext).
-