AxonFramework/AxonFramework — Issue #26: CommandTemplate
Author: abuijze
Created: 2012-01-02 10:59:31+00:00
State: open
Labels: Enhancement

Many applications make use of similar structures of sending commands and waiting for processing to complete. Although the SimpleCommandBus will always return when processing is done, this is not guaranteed by the interface.

Therefore, a CommandTemplate class can provide commonly used features. The CommandTemplate is constructed with a CommandBus and should be thread safe.
The operations it should provide, are:
- Object sendAndWait(Object command) throws ExecutionException, InterruptedException
- Object sendAndWait(Object command, int timeOut, TimeUnit timeUnit) throws ExecutionException, InterruptedException, TimeOutException
- Future send(Object command)

all methods will check for the type of Object provided. If the given command implements CommandMessage, it is sent as-is, otherwise, the parameter will automatically be wrapped as payload in a new CommandMessage.