Class DefaultReactorCommandGateway
- All Implemented Interfaces:
DescribableComponent,ReactorCommandGateway
ReactorCommandGateway.
Builds a recursive interceptor chain (same pattern as Axon Framework's
InterceptingCommandBus). The
entire chain runs inside the Reactor subscription, so interceptors have access to Reactor context such as
ReactiveSecurityContextHolder.
Flow:
- If the command is already a
CommandMessage, pass it through as-is; if it's a plainMessage, wrap it inGenericCommandMessage; otherwise create a newGenericCommandMessagefrom the payload usingMessageTypeResolver - Build chain: last link returns the message, each preceding link calls its interceptor
- Execute
chain.proceed(commandMessage)— runs inside the Reactor subscription - Dispatch the enriched message to the delegate
CommandGateway
- Since:
- 4.4.2
- Author:
- Milan Savic, Theo Emanuelsson
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultReactorCommandGateway(CommandGateway commandGateway, MessageTypeResolver messageTypeResolver) Instantiate aDefaultReactorCommandGatewaywithout dispatch interceptors.DefaultReactorCommandGateway(CommandGateway commandGateway, MessageTypeResolver messageTypeResolver, List<ReactorMessageDispatchInterceptor<? super CommandMessage>> dispatchInterceptors) Instantiate aDefaultReactorCommandGateway. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.<R> reactor.core.publisher.Mono<R> send(Object command, Class<R> resultType, @Nullable ProcessingContext context) Sends the givencommandin the providedcontext(if available) and returns aMonowith the typed result.reactor.core.publisher.Mono<Void> send(Object command, @Nullable ProcessingContext context) Sends the givencommandin the providedcontext(if available) and returns aMonothat completes when the command is handled.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.extension.reactor.messaging.commandhandling.gateway.ReactorCommandGateway
send, send
-
Constructor Details
-
DefaultReactorCommandGateway
public DefaultReactorCommandGateway(CommandGateway commandGateway, MessageTypeResolver messageTypeResolver, List<ReactorMessageDispatchInterceptor<? super CommandMessage>> dispatchInterceptors) Instantiate aDefaultReactorCommandGateway.- Parameters:
commandGateway- theCommandGatewayto delegate command dispatching tomessageTypeResolver- theMessageTypeResolverfor resolving message typesdispatchInterceptors- the list ofReactorMessageDispatchInterceptors to apply to commands
-
DefaultReactorCommandGateway
public DefaultReactorCommandGateway(CommandGateway commandGateway, MessageTypeResolver messageTypeResolver) Instantiate aDefaultReactorCommandGatewaywithout dispatch interceptors.- Parameters:
commandGateway- theCommandGatewayto delegate command dispatching tomessageTypeResolver- theMessageTypeResolverfor resolving message types
-
-
Method Details
-
send
public <R> reactor.core.publisher.Mono<R> send(Object command, Class<R> resultType, @Nullable ProcessingContext context) Description copied from interface:ReactorCommandGatewaySends the givencommandin the providedcontext(if available) and returns aMonowith the typed result.- Specified by:
sendin interfaceReactorCommandGateway- Type Parameters:
R- the result type- Parameters:
command- the command payload to sendresultType- the expected result typecontext- the processing context, if any, to dispatch the givencommandin- Returns:
- a
Monocompleting with the command result
-
send
Description copied from interface:ReactorCommandGatewaySends the givencommandin the providedcontext(if available) and returns aMonothat completes when the command is handled.- Specified by:
sendin interfaceReactorCommandGateway- Parameters:
command- the command payload to sendcontext- the processing context, if any, to dispatch the givencommandin- Returns:
- a
Monocompleting when the command is handled
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-