public interface CommandGateway
DefaultCommandGateway
Modifier and Type | Method and Description |
---|---|
<C,R> void |
send(C command,
CommandCallback<? super C,R> callback)
Sends the given
command , and have the result of the command's execution reported to the given
callback . |
<R> CompletableFuture<R> |
send(Object command)
Sends the given
command and returns immediately, without waiting for the command to execute. |
<R> R |
sendAndWait(Object command)
Sends the given
command and wait for it to execute. |
<R> R |
sendAndWait(Object command,
long timeout,
TimeUnit unit)
Sends the given
command and wait for it to execute. |
<C,R> void send(C command, CommandCallback<? super C,R> callback)
command
, and have the result of the command's execution reported to the given
callback
.
The given command
is wrapped as the payload of the CommandMessage that is eventually posted on the
Command Bus, unless Command already implements Message
. In that case, a
CommandMessage is constructed from that message's payload and MetaData.R
- The type of result expected from command executioncommand
- The command to dispatchcallback
- The callback to notify when the command has been processed<R> R sendAndWait(Object command)
command
and wait for it to execute. The result of the execution is returned when
available. This method will block indefinitely, until a result is available, or until the Thread is interrupted.
When the thread is interrupted, this method returns null
. If command execution resulted in an
exception, it is wrapped in a CommandExecutionException
.
The given command
is wrapped as the payload of the CommandMessage that is eventually posted on the
Command Bus, unless Command already implements Message
. In that case, a
CommandMessage is constructed from that message's payload and MetaData.
Note that the interrupted flag is set back on the thread if it has been interrupted while waiting.R
- The type of result expected from command executioncommand
- The command to dispatchnull
if the thread was interrupted while waiting for
the command to executeCommandExecutionException
- when an exception occurred while processing the command<R> R sendAndWait(Object command, long timeout, TimeUnit unit)
command
and wait for it to execute. The result of the execution is returned when
available. This method will block until a result is available, or the given timeout
was reached, or
until the Thread is interrupted. When the timeout is reached or the thread is interrupted, this method returns
null
. If command execution resulted in an exception, it is wrapped in a
CommandExecutionException
.
The given command
is wrapped as the payload of the CommandMessage that is eventually posted on the
Command Bus, unless Command already implements Message
. In that case, a
CommandMessage is constructed from that message's payload and MetaData.
Note that the interrupted flag is set back on the thread if it has been interrupted while waiting.R
- The type of result expected from command executioncommand
- The command to dispatchtimeout
- The amount of time the thread is allows to wait for the resultunit
- The unit in which timeout
is expressednull
if the thread was interrupted while waiting for
the command to executeCommandExecutionException
- when an exception occurred while processing the command<R> CompletableFuture<R> send(Object command)
command
and returns immediately, without waiting for the command to execute. The
caller will therefore not receive any feedback on the command's execution.
The given command
is wrapped as the payload of the CommandMessage that is eventually posted on the
Command Bus, unless Command already implements Message
. In that case, a
CommandMessage is constructed from that message's payload and MetaData.command
- The command to dispatchCompletableFuture
which is resolved when the command is executedCopyright © 2010–2018. All rights reserved.