Class DefaultEventGateway
- All Implemented Interfaces:
DescribableComponent,EventGateway
EventGateway interface using the EventSink to publish events.- Since:
- 4.1.0
- Author:
- Bert laverman, Mitchell Herrijgers
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultEventGateway(EventSink eventSink, MessageTypeResolver messageTypeResolver) Creates a newEventGatewaythat uses the giveneventSinkto publish events. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.publish(@Nullable ProcessingContext context, List<?> events) Publishes the giveneventswithin the givencontext.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.eventhandling.gateway.EventGateway
publish, publish
-
Constructor Details
-
DefaultEventGateway
Creates a newEventGatewaythat uses the giveneventSinkto publish events. ThemessageTypeResolveris used to resolve the type of the event if noEventMessageis provided but a payload.- Parameters:
eventSink- theEventSinkto publish events tomessageTypeResolver- theMessageTypeResolverto resolve the type of the event
-
-
Method Details
-
publish
Description copied from interface:EventGatewayPublishes the giveneventswithin the givencontext. When present, theeventsshould be published as part of thecontext'slifecycle.The
eventsare mapped toEventMessagesbefore they are given to anEventSink.- Specified by:
publishin interfaceEventGateway- Parameters:
context- The processing context, if any, to publish the giveneventsin.events- The collection of events to publish.- Returns:
- A
CompletableFutureofVoid. Completion of the future depends on theEventSinkused by this gateway.
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods 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
DescribableComponentimplementation 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 thedescribeTomethod, 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:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-