Interface ResultGateway
- All Superinterfaces:
Namespaced<ResultGateway>
- All Known Implementing Classes:
DefaultResultGateway, WebResponseGateway
The ResultGateway is used internally by Fluxzero to publish the result of a request, such as a
command or query, back to the requester. Each response must specify the target (usually a client ID) and a request ID
to correlate the result with the original request.
Responses can be sent as raw payloads or wrapped in a Message. Optionally, metadata and a
Guarantee can be supplied to control how delivery is handled.
Note: The results of handler methods—such as
HandleCommand or HandleQuery methods—are automatically published to the ResultGateway. This
interface is typically only used directly when you want to manually complete a request at a later time, such as after
receiving a third-party callback or performing asynchronous processing unrelated to the original handler method.
Example use case: Handling a payment gateway callback that matches a previously submitted command request.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionSends a response with the specified payload, metadata, target, request ID, and delivery guarantee.default CompletableFuture<Void> Sends a response message with default metadata andGuarantee.NONE.Methods inherited from interface Namespaced
forDefaultNamespace, forNamespace
-
Method Details
-
respond
Sends a response message with default metadata andGuarantee.NONE.If the provided response is a
Message, its payload and metadata are extracted and used directly. Otherwise, the response is wrapped as a newMessage.- Parameters:
response- the response object orMessageto be senttarget- the recipient of the response (typically a client ID)requestId- the unique ID of the original request- Returns:
- a
CompletableFuturethat completes when the message is published (depending on the guarantee)
-
respond
CompletableFuture<Void> respond(Object payload, Metadata metadata, String target, Integer requestId, Guarantee guarantee) Sends a response with the specified payload, metadata, target, request ID, and delivery guarantee.This method gives full control over how and when the response is delivered.
- Parameters:
payload- the payload of the responsemetadata- additional metadata to includetarget- the intended recipient of the responserequestId- the identifier of the original requestguarantee- delivery guarantee (e.g.,Guarantee.SENTorGuarantee.STORED)- Returns:
- a
CompletableFuturethat completes when the response is dispatched (depending on the guarantee)
-