Interface GenericGateway
- All Superinterfaces:
HasLocalHandlers
- All Known Implementing Classes:
DefaultGenericGateway
The GenericGateway
provides a uniform interface to send and receive messages over any standard or
user-defined topic, enabling extensibility beyond the default types such as commands, queries, events, and errors.
This interface supports asynchronous and synchronous message dispatching, both with and without awaiting a result. It also includes support for delivery guarantees and local handler registration.
Typical usage includes:
- Custom message flows that don’t fit standard message types
- Internal APIs that benefit from topic-based routing
- Feature-specific messaging with isolated topics
Obtaining a Gateway
UseFluxCapacitor.customGateway(String)
to create or retrieve a
GenericGateway
for a given topic:
GenericGateway myGateway = FluxCapacitor.customGateway("myTopic");
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this gateway and releases any underlying resources.default <R> CompletableFuture
<R> Sends aMessage
and returns a future that completes with its response payload.default <R> CompletableFuture
<R> Sends aRequest
message and returns a future with its typed response.default <R> CompletableFuture
<R> Sends aRequest
with metadata and returns a future with its response.default <R> CompletableFuture
<R> Sends a message (raw object orRequest
) and returns a future with its response.default <R> List
<CompletableFuture<R>> Sends multiple messages and returns a list of futures with their payload responses.default <R> CompletableFuture
<R> Sends a message with custom metadata and returns a future with its response.sendAndForget
(Guarantee guarantee, Message... messages) Sends multipleMessage
objects with a guarantee.default CompletableFuture
<Void> sendAndForget
(Guarantee guarantee, Object... messages) Sends multiple messages asynchronously with a specified delivery guarantee.default CompletableFuture
<Void> sendAndForget
(Message message, Guarantee guarantee) Sends aMessage
asynchronously with a given guarantee.default void
sendAndForget
(Object message) Sends a message asynchronously without waiting for a result or acknowledgement.default void
sendAndForget
(Object... messages) Sends multiple messages asynchronously withGuarantee.NONE
.default void
sendAndForget
(Object payload, Metadata metadata) Sends a message with custom payload and metadata asynchronously.default void
sendAndForget
(Object payload, Metadata metadata, Guarantee guarantee) Sends a message with payload, metadata, and delivery guarantee asynchronously.default <R> R
sendAndWait
(Message message) Sends a message and blocks for a result with a configurable timeout.default <R> R
sendAndWait
(Request<R> message) Sends aRequest
and blocks until a response is received.default <R> R
sendAndWait
(Request<R> payload, Metadata metadata) Sends aRequest
with metadata and blocks for a response.default <R> R
sendAndWait
(Object message) Sends a message and blocks until a response is received.default <R> R
sendAndWait
(Object payload, Metadata metadata) Sends a message with metadata and blocks for a response.default CompletableFuture
<Message> sendForMessage
(Message message) sendForMessages
(Message... messages) Sends multiple messages and returns futures for their fullMessage
responses.default void
setRetentionTime
(Duration duration) Set a new retention duration for the underlying gateway's message log.setRetentionTime
(Duration duration, Guarantee guarantee) Set a new retention duration for the underlying gateway's message log.Methods inherited from interface io.fluxcapacitor.javaclient.tracking.handling.HasLocalHandlers
hasLocalHandlers, registerHandler, registerHandler, setSelfHandlerFilter
-
Method Details
-
sendAndForget
Sends a message asynchronously without waiting for a result or acknowledgement. -
sendAndForget
Sends a message with custom payload and metadata asynchronously. -
sendAndForget
Sends a message with payload, metadata, and delivery guarantee asynchronously. -
sendAndForget
Sends aMessage
asynchronously with a given guarantee. -
sendAndForget
Sends multiple messages asynchronously withGuarantee.NONE
. -
sendAndForget
Sends multiple messages asynchronously with a specified delivery guarantee. -
sendAndForget
Sends multipleMessage
objects with a guarantee. -
send
Sends aMessage
and returns a future that completes with its response payload. -
send
Sends a message (raw object orRequest
) and returns a future with its response. -
send
Sends aRequest
message and returns a future with its typed response. -
send
Sends a message with custom metadata and returns a future with its response. -
send
Sends aRequest
with metadata and returns a future with its response. -
sendForMessage
-
send
Sends multiple messages and returns a list of futures with their payload responses. -
sendForMessages
Sends multiple messages and returns futures for their fullMessage
responses. -
sendAndWait
Sends a message and blocks until a response is received. -
sendAndWait
Sends aRequest
and blocks until a response is received. -
sendAndWait
Sends a message with metadata and blocks for a response. -
sendAndWait
Sends aRequest
with metadata and blocks for a response. -
sendAndWait
Sends a message and blocks for a result with a configurable timeout.Timeout can be customized using
@Timeout
on the payload class. -
setRetentionTime
Set a new retention duration for the underlying gateway's message log.The retention setting determines how long messages in this log are retained by the system, after which they may be evicted or deleted depending on the platform policy.
- Parameters:
duration
- the new retention duration
-
setRetentionTime
Set a new retention duration for the underlying gateway's message log.The retention setting determines how long messages in this log are retained by the system, after which they may be evicted or deleted depending on the platform policy.
- Parameters:
duration
- the new retention durationguarantee
- the delivery guarantee to apply to the update operation- Returns:
- a
CompletableFuture
that completes once the retention setting is updated
-
close
void close()Closes this gateway and releases any underlying resources.
-