Interface GenericGateway
- All Superinterfaces:
HasLocalHandlers, Namespaced<GenericGateway>
- 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
UseFluxzero.customGateway(String) to create or retrieve a
GenericGateway for a given topic:
GenericGateway myGateway = Fluxzero.customGateway("myTopic");
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this gateway and releases any underlying resources.default <R> CompletableFuture<R> Sends aMessageand returns a future that completes with its response payload.default <R> CompletableFuture<R> Sends aRequestmessage and returns a future with its typed response.default <R> CompletableFuture<R> Sends aRequestwith 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 multipleMessageobjects with a guarantee.default CompletableFuture<Void> sendAndForget(Guarantee guarantee, Object... messages) Sends multiple messages asynchronously with a specified delivery guarantee.sendAndForget(Guarantee guarantee, UnaryOperator<SerializedMessage> interceptor, Message... messages) Sends multipleMessageobjects with a guarantee.default CompletableFuture<Void> sendAndForget(Message message, Guarantee guarantee) Sends aMessageasynchronously with a given guarantee.default voidsendAndForget(Object message) Sends a message asynchronously without waiting for a result or acknowledgement.default voidsendAndForget(Object... messages) Sends multiple messages asynchronously withGuarantee.NONE.default voidsendAndForget(Object payload, Metadata metadata) Sends a message with custom payload and metadata asynchronously.default voidsendAndForget(Object payload, Metadata metadata, Guarantee guarantee) Sends a message with payload, metadata, and delivery guarantee asynchronously.<R> RsendAndWait(Message message) Sends a message and blocks for a result with a configurable timeout.default <R> RsendAndWait(Request<R> message) Sends aRequestand blocks until a response is received.default <R> RsendAndWait(Request<R> payload, Metadata metadata) Sends aRequestwith metadata and blocks for a response.default <R> RsendAndWait(Object message) Sends a message and blocks until a response is received.default <R> RsendAndWait(Object payload, Metadata metadata) Sends a message with metadata and blocks for a response.default CompletableFuture<Message> sendForMessage(Message message) sendForMessage(Message message, Duration timeout) Sends a single request message with the given effective timeout.sendForMessages(Message... messages) Sends multiple messages and returns futures for their fullMessageresponses.default voidsetRetentionTime(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.default CompletableFuture<Void> truncate()Truncates this gateway's message log and clears associated tracking positions usingGuarantee.STORED.Truncates this gateway's message log and clears associated tracking positions.Methods inherited from interface HasLocalHandlers
hasLocalHandlers, registerHandler, registerHandler, setSelfHandlerFilterMethods inherited from interface Namespaced
forDefaultNamespace, forNamespace
-
Method Details
-
sendAndForget
Sends a message asynchronously without waiting for a result or acknowledgement. -
sendAndForget
-
sendAndForget
-
sendAndForget
Sends aMessageasynchronously with a given guarantee. -
sendAndForget
Sends multiple messages asynchronously withGuarantee.NONE. -
sendAndForget
Sends multiple messages asynchronously with a specified delivery guarantee. -
sendAndForget
Sends multipleMessageobjects with a guarantee. -
sendAndForget
CompletableFuture<Void> sendAndForget(Guarantee guarantee, UnaryOperator<SerializedMessage> interceptor, Message... messages) Sends multipleMessageobjects with a guarantee.Before the messages are appended to the message log in Fluxzero, they can be inspected, blocked or modified using the given interceptor.
-
send
Sends aMessageand 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 aRequestmessage and returns a future with its typed response. -
send
Sends a message with custom metadata and returns a future with its response. -
send
Sends aRequestwith metadata and returns a future with its response. -
sendForMessage
-
sendForMessage
Sends a single request message with the given effective timeout.The effective timeout is used for the returned future and is propagated as request metadata so tracking handlers can skip stale indexed requests before invocation. If
timeoutisnull, the gateway falls back to timeout metadata already present on the message, then@Timeouton the payload class, and finally the request handler default. A negative timeout disables timeout handling for this request.- Parameters:
message- the message to sendtimeout- the timeout for this request;nulluses the gateway/request handler defaults- Returns:
- a future that completes with the response message
-
send
Sends multiple messages and returns a list of futures with their payload responses. -
sendForMessages
Sends multiple messages and returns futures for their fullMessageresponses. -
sendAndWait
Sends a message and blocks until a response is received. -
sendAndWait
-
sendAndWait
-
sendAndWait
-
sendAndWait
-
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
CompletableFuturethat completes once the retention setting is updated
-
truncate
Truncates this gateway's message log and clears associated tracking positions usingGuarantee.STORED.- Returns:
- a
CompletableFuturethat completes once the log is truncated
-
truncate
Truncates this gateway's message log and clears associated tracking positions.- Parameters:
guarantee- the delivery guarantee to apply to the truncate operation- Returns:
- a
CompletableFuturethat completes once the log is truncated
-
close
void close()Closes this gateway and releases any underlying resources.
-