org.axonframework.commandhandling.gateway
Class AbstractCommandGateway

java.lang.Object
  extended by org.axonframework.commandhandling.gateway.AbstractCommandGateway
Direct Known Subclasses:
DefaultCommandGateway

public abstract class AbstractCommandGateway
extends Object

Abstract implementation of a CommandGateway, which handles the dispatch interceptors and retrying on failure. The actual dispatching of commands is left to the subclasses.

Since:
2.2
Author:
Allard Buijze

Constructor Summary
protected AbstractCommandGateway(CommandBus commandBus, RetryScheduler retryScheduler, List<CommandDispatchInterceptor> commandDispatchInterceptors)
          Initialize the AbstractCommandGateway with given commandBus, retryScheduler and commandDispatchInterceptors.
 
Method Summary
protected  CommandMessage processInterceptors(CommandMessage commandMessage)
          Invokes all the dispatch interceptors and returns the CommandMessage instance that should be dispatched.
protected
<R> void
send(Object command, CommandCallback<R> callback)
          Sends the given command, and invokes the callback when the command is processed.
protected  void sendAndForget(Object command)
          Dispatches a command without callback.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCommandGateway

protected AbstractCommandGateway(CommandBus commandBus,
                                 RetryScheduler retryScheduler,
                                 List<CommandDispatchInterceptor> commandDispatchInterceptors)
Initialize the AbstractCommandGateway with given commandBus, retryScheduler and commandDispatchInterceptors.

Parameters:
commandBus - The command bus on which to dispatch events
retryScheduler - The scheduler capable of performing retries of failed commands. May be null when to prevent retries.
commandDispatchInterceptors - The interceptors to invoke when dispatching a command
Method Detail

send

protected <R> void send(Object command,
                        CommandCallback<R> callback)
Sends the given command, and invokes the callback when the command is processed.

Type Parameters:
R - The type of response expected from the command
Parameters:
command - The command to dispatch
callback - The callback to notify with the processing result

sendAndForget

protected void sendAndForget(Object command)
Dispatches a command without callback. When dispatching fails, since there is no callback, the command will not be retried.

Parameters:
command - The command to dispatch

processInterceptors

protected CommandMessage processInterceptors(CommandMessage commandMessage)
Invokes all the dispatch interceptors and returns the CommandMessage instance that should be dispatched.

Parameters:
commandMessage - The incoming command message
Returns:
The command message to dispatch


Copyright © 2010-2016. All Rights Reserved.