Interface GenericGateway
- All Superinterfaces:
AutoCloseable, 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 typed request with a per-call publication guarantee and returns its business response future.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.default <R> CompletableFuture<R> Sends a request with the given publication guarantee.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 with the application'sGuarantee.DEFAULTwithout waiting for a result or remote acknowledgement.default voidsendAndForget(Object... messages) Sends multiple messages asynchronously withGuarantee.DEFAULT.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(Request<R> payload, Metadata metadata, Guarantee guarantee) Sends a typed request with a per-call publication guarantee and waits for its business 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 <R> RsendAndWait(Object payload, Metadata metadata, Guarantee guarantee) Sends a request with a per-call publication guarantee and waits for its business response.default CompletableFuture<Message> sendForMessage(Message message) sendForMessage(Message message, Duration timeout) Sends a single request message with the given effective timeout.default CompletableFuture<Message> sendForMessage(Message message, Duration timeout, Guarantee guarantee) Sends a full request with a per-call publication guarantee and effective timeout.default List<CompletableFuture<Message>> sendForMessages(Guarantee guarantee, Message... messages) Sends full request messages with one publication guarantee and returns business response futures in input order.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.DEFAULT.Truncates this gateway's message log and clears associated tracking positions.Methods inherited from interface HasLocalHandlers
hasLocalHandlers, registerHandler, registerHandler, setSelfHandlerFilterMethods inherited from interface Namespaced
forApplicationNamespace, forDefaultNamespace, forNamespace
-
Method Details
-
sendAndForget
Sends a message with the application'sGuarantee.DEFAULTwithout waiting for a result or remote acknowledgement. A participating tracking completion scope awaits delivery before committing its consumer position; seeConsumer.awaitOutgoingWrites()for opt-outs and streaming boundaries. Outside tracking, use a future-returning overload to observe delivery confirmation or asynchronous failures. -
sendAndForget
-
sendAndForget
-
sendAndForget
Sends aMessageasynchronously with a given guarantee. -
sendAndForget
Sends multiple messages asynchronously withGuarantee.DEFAULT. -
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 according to the selected delivery guarantee
-
truncate
Truncates this gateway's message log and clears associated tracking positions usingGuarantee.DEFAULT.- Returns:
- a
CompletableFuturethat completes according to the selected delivery guarantee
-
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 according to the selected delivery guarantee
-
close
void close()Closes this gateway and releases any underlying resources.- Specified by:
closein interfaceAutoCloseable
-
send
Sends a request with the given publication guarantee. The future represents its business response.Guarantee.DEFAULTusesfluxzero.publishing.defaultGuarantee, with the SDK major-version request default when unconfigured.Guarantee.NONE,Guarantee.SENTandGuarantee.STOREDoverride publication for this call only; the business result is still awaited.- Type Parameters:
R- response payload type- Parameters:
payload- request payloadmetadata- request metadata; useMetadata.empty()when none is neededguarantee- request publication guarantee- Returns:
- the business response future
-
send
Sends a typed request with a per-call publication guarantee and returns its business response future. -
sendAndWait
-
sendAndWait
-
sendForMessages
Sends full request messages with one publication guarantee and returns business response futures in input order. Custom gateways retain their existing batch behavior forDEFAULT; unsupported explicit guarantees fail. -
sendForMessage
default CompletableFuture<Message> sendForMessage(Message message, Duration timeout, Guarantee guarantee) Sends a full request with a per-call publication guarantee and effective timeout. Timeout interpretation is identical tosendForMessage(Message, Duration). Custom gateways retain their existing timeout behavior forDEFAULT; unsupported explicit guarantees fail.
-