Class SubscribingEventProcessor

java.lang.Object
org.axonframework.messaging.eventhandling.processing.subscribing.SubscribingEventProcessor
All Implemented Interfaces:
DescribableComponent, EventProcessor

public class SubscribingEventProcessor extends Object implements EventProcessor
Event processor implementation that subscribes to the EventBus for events. Events published on the event bus are supplied to this processor in the publishing thread.

Since:
3.0.0
Author:
Rene de Waele
  • Constructor Details

  • Method Details

    • name

      public String name()
      Description copied from interface: EventProcessor
      Returns the name of this event processor. This name is used to detect distributed instances of the same event processor. Multiple instances referring to the same logical event processor (on different JVM's) must have the same name.
      Specified by:
      name in interface EventProcessor
      Returns:
      the name of this event processor
    • start

      public CompletableFuture<Void> start()
      Start this processor. This will register the processor with the EventBus.

      Upon start up of an application, this method will be invoked in the Phase.LOCAL_MESSAGE_HANDLER_REGISTRATIONS phase.

      Specified by:
      start in interface EventProcessor
      Returns:
      a CompletableFuture that completes when the start process is finished.
    • isRunning

      public boolean isRunning()
      Description copied from interface: EventProcessor
      Indicates whether this processor is currently running (i.e. consuming events from its message source).
      Specified by:
      isRunning in interface EventProcessor
      Returns:
      true when running, otherwise false
    • isError

      public boolean isError()
      Description copied from interface: EventProcessor
      Indicates whether the processor has been shut down due to an error. In such case, the processor has forcefully shut down, as it wasn't able to automatically recover.

      Note that this method returns false when the processor was stopped using EventProcessor.shutdown().

      Specified by:
      isError in interface EventProcessor
      Returns:
      true when paused due to an error, otherwise false
    • process

      protected void process(@Nonnull List<EventMessage> eventMessages, @Nullable ProcessingContext context)
      Process the given messages. A Unit of Work must be created for this processing.

      This implementation creates a Batching unit of work for the given batch of eventMessages.

      Parameters:
      eventMessages - The messages to process
    • shutdown

      public CompletableFuture<Void> shutdown()
      Shut down this processor. This will deregister the processor with the EventBus.

      Upon shutdown of an application, this method will be invoked in the Phase.LOCAL_MESSAGE_HANDLER_REGISTRATIONS phase.

      Specified by:
      shutdown in interface EventProcessor
      Returns:
      a CompletableFuture that completes when the shutdown process is finished.
    • 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
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.