Interface QueryGateway
- All Superinterfaces:
HasLocalHandlers, Namespaced<QueryGateway>
- All Known Implementing Classes:
DefaultQueryGateway
Gateway interface for dispatching queries and receiving responses in Fluxzero.
The QueryGateway provides a high-level API for submitting queries and retrieving
results, either asynchronously or synchronously. It supports rich metadata and integrates with
both local and remote query handlers.
Queries can be sent as raw payloads, Message objects, or Request wrappers for typed responses.
This interface also supports registration of local handlers via HasLocalHandlers.registerHandler(Object).
For message types that are queries, the MessageType.QUERY enum is typically used.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Gracefully shuts down this gateway and releases any held resources.<R> CompletableFuture<R> Sends a typedRequestquery and returns a future representing the result.<R> CompletableFuture<R> Sends a typedRequestquery with additional metadata and returns a future with the result.default <R> CompletableFuture<R> send(Request<R> payload, io.fluxzero.common.api.Metadata metadata, io.fluxzero.common.Guarantee guarantee) Sends a typed request with a per-call publication guarantee and returns its business response future.<R> CompletableFuture<R> Sends the given query asynchronously and returns a future representing the result.<R> List<CompletableFuture<R>> Sends multiple queries asynchronously and returns a list of futures, one for each result.<R> CompletableFuture<R> Sends the given query along with metadata asynchronously and returns a future representing the result.default <R> CompletableFuture<R> send(Object payload, io.fluxzero.common.api.Metadata metadata, io.fluxzero.common.Guarantee guarantee) Sends a request with the given publication guarantee.<R> RsendAndWait(Request<R> query) Sends a typedRequestquery and waits for the result.<R> RsendAndWait(Request<R> payload, io.fluxzero.common.api.Metadata metadata) Sends a typedRequestquery with metadata and waits for the result.default <R> RsendAndWait(Request<R> payload, io.fluxzero.common.api.Metadata metadata, io.fluxzero.common.Guarantee guarantee) Sends a typed request with a per-call publication guarantee and waits for its business response.<R> RsendAndWait(Object query) Sends the given query and waits for the result, blocking the current thread.<R> RsendAndWait(Object payload, io.fluxzero.common.api.Metadata metadata) Sends the given query and metadata, then waits for the result.default <R> RsendAndWait(Object payload, io.fluxzero.common.api.Metadata metadata, io.fluxzero.common.Guarantee guarantee) Sends a request with a per-call publication guarantee and waits for its business response.sendForMessage(Message message) Sends the givenMessageand returns a future representing the resulting message.default List<CompletableFuture<Message>> sendForMessages(io.fluxzero.common.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 queryMessages and returns a list of futures for the raw responses.Methods inherited from interface HasLocalHandlers
hasLocalHandlers, registerHandler, registerHandler, setSelfHandlerFilterMethods inherited from interface Namespaced
forApplicationNamespace, forDefaultNamespace, forNamespace
-
Method Details
-
send
Sends the given query asynchronously and returns a future representing the result.If the query is a
Message, it is dispatched as-is. Otherwise, it is wrapped in a new message.- Type Parameters:
R- the expected type of the result- Parameters:
query- the query object- Returns:
- a
CompletableFuturewith the result
-
send
Sends the given query along with metadata asynchronously and returns a future representing the result.- Type Parameters:
R- the expected result type- Parameters:
payload- the query payloadmetadata- additional metadata to attach to the message- Returns:
- a
CompletableFuturecontaining the query result
-
sendForMessage
Sends the givenMessageand returns a future representing the resulting message. This method gives access to the fullMessagereturned by the query handler.- Parameters:
message- the message representing the query- Returns:
- a
CompletableFuturewith the response message
-
send
Sends multiple queries asynchronously and returns a list of futures, one for each result.- Type Parameters:
R- the expected result type for each query- Parameters:
messages- one or more query objects or messages- Returns:
- a list of
CompletableFutures for each query result
-
sendForMessages
Sends multiple queryMessages and returns a list of futures for the raw responses.- Parameters:
messages- one or more messages representing queries- Returns:
- a list of
CompletableFutures containing the result messages
-
sendAndWait
Sends the given query and waits for the result, blocking the current thread.- Type Parameters:
R- the expected result type- Parameters:
query- the query object- Returns:
- the result of the query
-
sendAndWait
Sends the given query and metadata, then waits for the result.- Type Parameters:
R- the expected result type- Parameters:
payload- the query payloadmetadata- additional metadata to attach to the query- Returns:
- the result of the query
-
send
Sends a typedRequestquery and returns a future representing the result.- Type Parameters:
R- the expected result type- Parameters:
query- theRequestquery- Returns:
- a
CompletableFuturecontaining the result
-
send
Sends a typedRequestquery with additional metadata and returns a future with the result.- Type Parameters:
R- the expected result type- Parameters:
payload- theRequestpayloadmetadata- metadata to attach to the request- Returns:
- a
CompletableFuturewith the result
-
sendAndWait
-
sendAndWait
-
close
void close()Gracefully shuts down this gateway and releases any held resources. -
send
default <R> CompletableFuture<R> send(Object payload, io.fluxzero.common.api.Metadata metadata, io.fluxzero.common.Guarantee guarantee) 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
default <R> CompletableFuture<R> send(Request<R> payload, io.fluxzero.common.api.Metadata metadata, io.fluxzero.common.Guarantee guarantee) Sends a typed request with a per-call publication guarantee and returns its business response future. -
sendAndWait
default <R> R sendAndWait(Object payload, io.fluxzero.common.api.Metadata metadata, io.fluxzero.common.Guarantee guarantee) Sends a request with a per-call publication guarantee and waits for its business response. Storage acknowledgment does not replace or delay an already available business response. -
sendAndWait
default <R> R sendAndWait(Request<R> payload, io.fluxzero.common.api.Metadata metadata, io.fluxzero.common.Guarantee guarantee) Sends a typed request with a per-call publication guarantee and waits for its business response. -
sendForMessages
default List<CompletableFuture<Message>> sendForMessages(io.fluxzero.common.Guarantee guarantee, Message... messages) 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.
-