Class ProcessorEventHandlingComponents

java.lang.Object
org.axonframework.messaging.eventhandling.processing.ProcessorEventHandlingComponents
All Implemented Interfaces:
DescribableComponent

@Internal public class ProcessorEventHandlingComponents extends Object implements DescribableComponent
Internal class for managing multiple EventHandlingComponent instances and processing event messages through them. Each event handling component is wrapped in a SequencingEventHandlingComponent to ensure proper sequencing where required.

Key responsibilities include:

  • Distributing event messages to the associated EventHandlingComponent instances.
  • Ensuring event handling sequencing policies are respected when applicable.
  • Determining support for specific event types across the managed components.
Since:
5.0.0
Author:
Mateusz Nowak
  • Constructor Details

    • ProcessorEventHandlingComponents

      public ProcessorEventHandlingComponents(List<EventHandlingComponent> components)
      Constructs a ProcessorEventHandlingComponents instance by wrapping the provided list of EventHandlingComponents in SequencingEventHandlingComponent instances for sequential event handling where needed.
      Parameters:
      components - The list of EventHandlingComponents to be used for event processing. Must not be null and is transformed into a list of SequencingEventHandlingComponents if necessary.
  • Method Details

    • handle

      public MessageStream.Empty<Message> handle(List<? extends EventMessage> events, ProcessingContext context)
      Processes a batch of events in the processing context.

      The result of handling is an empty stream. It's guaranteed that the events with same sequenceIdentifiersFor(EventMessage, ProcessingContext) value are processed by a single component in the order they are received, but the sequencing of event processing is not preserved between different event handling components. This is intentional, as they may have different sequencing policies.

      Parameters:
      events - The batch of event messages to be processed.
      context - The processing context in which the event messages are processed.
      Returns:
      A stream of messages resulting from the processing of the event messages.
    • supportedEvents

      public Set<QualifiedName> supportedEvents()
      Retrieves a set of all event names supported by the components comprising this ProcessorEventHandlingComponents instance. Each event is referenced through a QualifiedName.
      Returns:
      A set of QualifiedName objects representing the supported events.
    • supports

      public boolean supports(QualifiedName eventName)
      Checks if the specified event name is supported by any of the components.
      Parameters:
      eventName - The qualified name of the event to be checked. Must not be null.
      Returns:
      true if the event name is supported, false otherwise.
    • sequenceIdentifiersFor

      public Set<Object> sequenceIdentifiersFor(EventMessage event, ProcessingContext context)
      Retrieves a set of sequence identifiers for the given event message and processing context. Each identifier represents a sequence property determined by the components within this instance.
      Parameters:
      event - The event message for which the sequence identifiers are to be determined. Must not be null.
      context - The processing context in which the sequence identifiers are evaluated. Must not be null.
      Returns:
      A set of sequence identifiers associated with the given event and context.
    • handleReset

      public CompletableFuture<Void> handleReset(ResetContext resetContext, ProcessingContext context)
      Handles reset for all components that support it.

      This method invokes the reset handler on each component that supports reset operations. All handlers must complete successfully for the operation to succeed.

      Parameters:
      resetContext - The reset context message.
      context - The processing context.
      Returns:
      A future that completes when all reset handlers have completed.
    • supportsReset

      public boolean supportsReset()
      Checks if any component supports reset operations.
      Returns:
      true if at least one component supports reset, false otherwise.
    • replayStarted

      public CompletableFuture<Void> replayStarted(ProcessingContext context)
      Handles the start of a replay for all components.

      This method invokes the ReplayStatusChangedHandlers on each component. All handlers must complete successfully for the operation to succeed.

      Parameters:
      context - the processing context
      Returns:
      a future that completes when all ReplayStatusChangedHandlers have completed
    • 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.