Interface CommandGateway
- All Superinterfaces:
HasLocalHandlers
- All Known Implementing Classes:
DefaultCommandGateway
Gateway interface for publishing command messages in Flux Capacitor.
Commands represent intent—typically something that should change state in the application. They are handled by
command handlers (annotated with HandleCommand
) and may yield
results or raise validation errors.
This gateway supports fire-and-forget invocation as well as synchronous and asynchronous sending of commands with or
without results. Commands may be published as raw payloads or wrapped
Message
objects.
Implementations of this interface may also invoke local handlers when available, as exposed via
HasLocalHandlers
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Shuts down the command gateway.<R> CompletableFuture
<R> Sends a typed request command and returns a future for the result.<R> CompletableFuture
<R> Sends a typed request command with metadata and returns a future for the result.<R> CompletableFuture
<R> Sends a command and returns a future for the result.<R> List
<CompletableFuture<R>> Sends multiple commands and returns futures for their results.<R> CompletableFuture
<R> Sends a command with metadata and returns a future for the result.sendAndForget
(Guarantee guarantee, Object... messages) Sends multiple commands with a delivery guarantee without waiting for results.void
sendAndForget
(Object command) Sends a command without waiting for a result.void
sendAndForget
(Object... messages) Sends multiple commands without waiting for results.void
sendAndForget
(Object payload, Metadata metadata) Sends a command with metadata without waiting for a result.void
sendAndForget
(Object payload, Metadata metadata, Guarantee guarantee) Sends a command with metadata and delivery guarantee, without waiting for a result.<R> R
sendAndWait
(Request<R> query) Sends a typed request command and waits for the result.<R> R
sendAndWait
(Request<R> payload, Metadata metadata) Sends a typed request command with metadata and waits for the result.<R> R
sendAndWait
(Object command) Sends a command and waits for the result.<R> R
sendAndWait
(Object payload, Metadata metadata) Sends a command with metadata and waits for the result.sendForMessage
(Message message) sendForMessages
(Message... messages) Sends multiple messages and returns futures for the result messages.Methods inherited from interface io.fluxcapacitor.javaclient.tracking.handling.HasLocalHandlers
hasLocalHandlers, registerHandler, registerHandler, setSelfHandlerFilter
-
Method Details
-
sendAndForget
Sends a command without waiting for a result.- Parameters:
command
- the command to send
-
sendAndForget
Sends a command with metadata without waiting for a result.- Parameters:
payload
- the command payloadmetadata
- metadata to include
-
sendAndForget
Sends a command with metadata and delivery guarantee, without waiting for a result.- Parameters:
payload
- the command payloadmetadata
- metadata to includeguarantee
- the delivery guarantee (e.g., stored before ack)
-
sendAndForget
Sends multiple commands without waiting for results.- Parameters:
messages
- the commands to send
-
sendAndForget
Sends multiple commands with a delivery guarantee without waiting for results.- Parameters:
guarantee
- the delivery guaranteemessages
- the commands to send- Returns:
- a future that completes when all commands have been sent
-
send
Sends a command and returns a future for the result.- Type Parameters:
R
- the expected result type- Parameters:
command
- the command to send- Returns:
- a future with the command's result
-
send
Sends a command with metadata and returns a future for the result.- Type Parameters:
R
- the expected result type- Parameters:
payload
- the command payloadmetadata
- metadata to include- Returns:
- a future with the command's result
-
sendForMessage
- Parameters:
message
- the message to send- Returns:
- a future with the result message
-
send
Sends multiple commands and returns futures for their results.- Type Parameters:
R
- the expected result type- Parameters:
messages
- the commands to send- Returns:
- a list of futures with each command's result
-
sendForMessages
Sends multiple messages and returns futures for the result messages.- Parameters:
messages
- the messages to send- Returns:
- a list of futures with the resulting messages
-
sendAndWait
Sends a command and waits for the result.- Type Parameters:
R
- the expected result type- Parameters:
command
- the command to send- Returns:
- the result of the command
-
sendAndWait
Sends a command with metadata and waits for the result.- Type Parameters:
R
- the expected result type- Parameters:
payload
- the command payloadmetadata
- metadata to include- Returns:
- the result of the command
-
send
Sends a typed request command and returns a future for the result.- Type Parameters:
R
- the result type- Parameters:
query
- the request command- Returns:
- a future with the command's result
-
send
Sends a typed request command with metadata and returns a future for the result.- Type Parameters:
R
- the result type- Parameters:
payload
- the request commandmetadata
- metadata to include- Returns:
- a future with the command's result
-
sendAndWait
Sends a typed request command and waits for the result.- Type Parameters:
R
- the result type- Parameters:
query
- the request command- Returns:
- the result of the command
-
sendAndWait
Sends a typed request command with metadata and waits for the result.- Type Parameters:
R
- the result type- Parameters:
payload
- the request commandmetadata
- metadata to include- Returns:
- the result of the command
-
close
void close()Shuts down the command gateway.
-