Class DefaultReactorCommandGateway

java.lang.Object
org.axonframework.extension.reactor.messaging.commandhandling.gateway.DefaultReactorCommandGateway
All Implemented Interfaces:
DescribableComponent, ReactorCommandGateway

public class DefaultReactorCommandGateway extends Object implements ReactorCommandGateway
Default implementation of 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:

  1. If the command is already a CommandMessage, pass it through as-is; if it's a plain Message, wrap it in GenericCommandMessage; otherwise create a new GenericCommandMessage from the payload using MessageTypeResolver
  2. Build chain: last link returns the message, each preceding link calls its interceptor
  3. Execute chain.proceed(commandMessage) — runs inside the Reactor subscription
  4. Dispatch the enriched message to the delegate CommandGateway
Since:
4.4.2
Author:
Milan Savic, Theo Emanuelsson
See Also:
  • Constructor Details

  • Method Details

    • send

      public <R> reactor.core.publisher.Mono<R> send(Object command, Class<R> resultType, @Nullable ProcessingContext context)
      Description copied from interface: ReactorCommandGateway
      Sends the given command in the provided context (if available) and returns a Mono with the typed result.
      Specified by:
      send in interface ReactorCommandGateway
      Type Parameters:
      R - the result type
      Parameters:
      command - the command payload to send
      resultType - the expected result type
      context - the processing context, if any, to dispatch the given command in
      Returns:
      a Mono completing with the command result
    • send

      public reactor.core.publisher.Mono<Void> send(Object command, @Nullable ProcessingContext context)
      Description copied from interface: ReactorCommandGateway
      Sends the given command in the provided context (if available) and returns a Mono that completes when the command is handled.
      Specified by:
      send in interface ReactorCommandGateway
      Parameters:
      command - the command payload to send
      context - the processing context, if any, to dispatch the given command in
      Returns:
      a Mono completing when the command is handled
    • describeTo

      public void describeTo(ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods 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 DescribableComponent implementation 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 the describeTo method, 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:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.