Interface EventGateway
- All Superinterfaces:
HasLocalHandlers
- All Known Implementing Classes:
DefaultEventGateway
Events represent facts that have occurred and are typically used for downstream processing, projections, or integration with other systems. Unlike commands and queries, events are not expected to produce a response.
This gateway supports both local and remote event publishing. If local handlers are registered (via
HasLocalHandlers.registerHandler(Object)
), those will be invoked in-process. Otherwise, or in addition, the events are
published to the Flux platform for delivery to interested consumers.
Note that publishing an event via this gateway does not associate it with an aggregate. If you're
implementing an event-sourced aggregate, use Entity.apply(java.lang.Object...)
instead to
apply domain events to the aggregate and persist them in the event store.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionPublishes one or more event messages with a specific delivery guarantee.Publishes the givenMessage
to Flux Capacitor and/or local handlers.default void
Publishes the given event object.void
Publishes one or more event messages.default void
Publishes an event with the specified payload and metadata.Methods inherited from interface io.fluxcapacitor.javaclient.tracking.handling.HasLocalHandlers
hasLocalHandlers, registerHandler, registerHandler, setSelfHandlerFilter
-
Method Details
-
publish
Publishes the given event object. If the object is not already aMessage
, it will be wrapped in one. The event is published with no delivery guarantee.If local handlers are registered, they will be invoked synchronously.
- Parameters:
event
- the event object to publish- Throws:
RuntimeException
- if an error occurs during publishing
-
publish
Publishes an event with the specified payload and metadata. The event is wrapped into aMessage
. The event is published with no delivery guarantee.If local handlers are registered, they will be invoked synchronously.
- Parameters:
payload
- the event payloadmetadata
- the associated metadata- Throws:
RuntimeException
- if an error occurs during publishing
-
publish
Publishes the givenMessage
to Flux Capacitor and/or local handlers. Returns a future that completes when the message has been fully processed or stored according to the givenGuarantee
.- Parameters:
message
- the message to publishguarantee
- the level of delivery guarantee to apply (e.g., store-before-acknowledge)- Returns:
- a future that completes when the message has been handled
-
publish
Publishes one or more event messages. Each message may be a raw payload or aMessage
instance. Events are published with no delivery guarantee.This method does not block for completion or acknowledgments.
- Parameters:
messages
- the events to publish
-
publish
Publishes one or more event messages with a specific delivery guarantee. Each message may be a raw payload or aMessage
instance.Returns a future that completes when the messages have been handled or stored according to the specified
Guarantee
.- Parameters:
guarantee
- the delivery guarantee (e.g.,Guarantee.STORED
)messages
- the events to publish- Returns:
- a future that completes upon publishing
-