Class DefaultEventGateway

java.lang.Object
org.axonframework.messaging.eventhandling.gateway.DefaultEventGateway
All Implemented Interfaces:
DescribableComponent, EventGateway

public class DefaultEventGateway extends Object implements EventGateway
Default implementation of the EventGateway interface using the EventSink to publish events.
Since:
4.1.0
Author:
Bert laverman, Mitchell Herrijgers
  • Constructor Details

    • DefaultEventGateway

      public DefaultEventGateway(EventSink eventSink, MessageTypeResolver messageTypeResolver)
      Creates a new EventGateway that uses the given eventSink to publish events. The messageTypeResolver is used to resolve the type of the event if no EventMessage is provided but a payload.
      Parameters:
      eventSink - the EventSink to publish events to
      messageTypeResolver - the MessageTypeResolver to resolve the type of the event
  • Method Details

    • publish

      public CompletableFuture<Void> publish(@Nullable ProcessingContext context, List<?> events)
      Description copied from interface: EventGateway
      Publishes the given events within the given context. When present, the events should be published as part of the context's lifecycle.

      The events are mapped to EventMessages before they are given to an EventSink.

      Specified by:
      publish in interface EventGateway
      Parameters:
      context - The processing context, if any, to publish the given events in.
      events - The collection of events to publish.
      Returns:
      A CompletableFuture of Void. Completion of the future depends on the EventSink used by this gateway.
    • 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.