public class DefaultCommandGateway extends AbstractCommandGateway implements CommandGateway
RetryScheduler and
CommandDispatchInterceptors. The Retry Scheduler allows for Command to be
automatically retried when a non-transient exception occurs. The Command Dispatch Interceptors can intercept and
alter command dispatched on this specific gateway. Typically, this would be used to add gateway specific meta data
to the Command.| Constructor and Description |
|---|
DefaultCommandGateway(CommandBus commandBus,
CommandDispatchInterceptor... commandDispatchInterceptors)
Initializes a command gateway that dispatches commands to the given
commandBus after they have been
handles by the given commandDispatchInterceptors. |
DefaultCommandGateway(CommandBus commandBus,
RetryScheduler retryScheduler,
CommandDispatchInterceptor... commandDispatchInterceptors)
Initializes a command gateway that dispatches commands to the given
commandBus after they have been
handles by the given commandDispatchInterceptors. |
DefaultCommandGateway(CommandBus commandBus,
RetryScheduler retryScheduler,
List<CommandDispatchInterceptor> commandDispatchInterceptors)
Initializes a command gateway that dispatches commands to the given
commandBus after they have been
handles by the given commandDispatchInterceptors. |
| Modifier and Type | Method and Description |
|---|---|
void |
send(Object command)
Sends the given
command and returns immediately. |
<R> void |
send(Object command,
CommandCallback<R> callback)
Sends the given
command, and invokes the callback when the command is processed. |
<R> R |
sendAndWait(Object command)
Sends the given
command and waits for its execution to complete, or until the waiting thread is
interrupted. |
<R> R |
sendAndWait(Object command,
long timeout,
TimeUnit unit)
Sends the given
command and waits for its execution to complete, or until the given
timeout has expired, or the waiting thread is interrupted. |
processInterceptors, sendAndForgetpublic DefaultCommandGateway(CommandBus commandBus, CommandDispatchInterceptor... commandDispatchInterceptors)
commandBus after they have been
handles by the given commandDispatchInterceptors. Commands will not be retried when command
execution fails.commandBus - The CommandBus on which to dispatch the Command MessagescommandDispatchInterceptors - The interceptors to invoke before dispatching commands to the Command Buspublic DefaultCommandGateway(CommandBus commandBus, RetryScheduler retryScheduler, CommandDispatchInterceptor... commandDispatchInterceptors)
commandBus after they have been
handles by the given commandDispatchInterceptors. When command execution results in an unchecked
exception, the given retryScheduler is invoked to allow it to retry that command.
execution fails.commandBus - The CommandBus on which to dispatch the Command MessagesretryScheduler - The scheduler that will decide whether to reschedule commandscommandDispatchInterceptors - The interceptors to invoke before dispatching commands to the Command Buspublic DefaultCommandGateway(CommandBus commandBus, RetryScheduler retryScheduler, List<CommandDispatchInterceptor> commandDispatchInterceptors)
commandBus after they have been
handles by the given commandDispatchInterceptors. When command execution results in an unchecked
exception, the given retryScheduler is invoked to allow it to retry that command.
execution fails.commandBus - The CommandBus on which to dispatch the Command MessagesretryScheduler - The scheduler that will decide whether to reschedule commandscommandDispatchInterceptors - The interceptors to invoke before dispatching commands to the Command Buspublic <R> void send(Object command, CommandCallback<R> callback)
AbstractCommandGatewaycommand, and invokes the callback when the command is processed.send in interface CommandGatewaysend in class AbstractCommandGatewayR - The type of response expected from the commandcommand - The command to dispatchcallback - The callback to notify with the processing resultpublic <R> R sendAndWait(Object command)
command and waits for its execution to complete, or until the waiting thread is
interrupted.sendAndWait in interface CommandGatewayR - The expected type of return valuecommand - The command to sendCommandExecutionException - when command execution threw a checked exceptionpublic <R> R sendAndWait(Object command, long timeout, TimeUnit unit)
command and waits for its execution to complete, or until the given
timeout has expired, or the waiting thread is interrupted.
When the timeout occurs, or the thread is interrupted, this method returns null.sendAndWait in interface CommandGatewayR - The expected type of return valuecommand - The command to sendtimeout - The maximum time to waitunit - The time unit of the timeout argumentCommandExecutionException - when command execution threw a checked exceptionpublic void send(Object command)
command and returns immediately. This implementationsend in interface CommandGatewaycommand - The command to sendCopyright © 2010-2014. All Rights Reserved.