Class InterceptingEventHandlingComponent

java.lang.Object
org.axonframework.messaging.eventhandling.DelegatingEventHandlingComponent
org.axonframework.messaging.eventhandling.interception.InterceptingEventHandlingComponent
All Implemented Interfaces:
DescribableComponent, MessageHandler, EventHandler, EventHandlingComponent

@Internal public class InterceptingEventHandlingComponent extends DelegatingEventHandlingComponent
An EventHandlingComponent implementation that supports intercepting event handling through MessageHandlerInterceptors. This component delegates actual event handling to another EventHandlingComponent while applying configured interceptors to the message handling process.
Since:
5.0.0
Author:
Allard Buijze, Mateusz Nowak, Mitchell Herrijgers, Steven van Beelen
  • Field Details

    • DECORATION_ORDER

      public static final int DECORATION_ORDER
      The order in which the InterceptingEventHandlingComponent is applied as a decorator to an EventHandlingComponent.

      As such, any decorator with a lower value will be applied to the delegate, and any higher value will be applied to the InterceptingEventHandlingComponent itself. Using the same value can either lead to application of the decorator to the delegate or the InterceptingEventHandlingComponent, depending on the order of registration.

      The order of the InterceptingEventHandlingComponent is set to Integer.MIN_VALUE + 100 to ensure it is applied very early in the configuration process, but not the earliest to allow for other decorators to be applied.

      See Also:
  • Constructor Details

    • InterceptingEventHandlingComponent

      public InterceptingEventHandlingComponent(@Nonnull List<MessageHandlerInterceptor<? super EventMessage>> messageHandlerInterceptors, @Nonnull EventHandlingComponent delegate)
      Constructs the component with the given delegate and interceptors.
      Parameters:
      messageHandlerInterceptors - The list of interceptors to initialize with.
      delegate - The EventHandlingComponent to delegate to.
  • Method Details

    • handle

      @Nonnull public MessageStream.Empty<Message> handle(@Nonnull EventMessage event, @Nonnull ProcessingContext context)
      Description copied from interface: EventHandler
      Handles the given event within the given context.

      The result of handling is an empty stream.

      Specified by:
      handle in interface EventHandler
      Overrides:
      handle in class DelegatingEventHandlingComponent
      Parameters:
      event - The event to handle.
      context - The context to the given event is handled in.
      Returns:
      An empty stream containing nothing.
    • describeTo

      public void describeTo(@Nonnull 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
      Overrides:
      describeTo in class DelegatingEventHandlingComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.