public class AsynchronousCommandBus extends SimpleCommandBus
Executors.newCachedThreadPool()). It will reuse threads while possible, and shut them
down after 60 seconds of inactivity.
Each Command is dispatched in a separate task, which is processed by the Executor.
Note that you should call shutdown() to stop any threads waiting for new tasks. Failure to do so may cause
the JVM to hang for up to 60 seconds on JVM shutdown.| Modifier and Type | Class and Description |
|---|---|
static class |
AsynchronousCommandBus.Builder
Builder class to instantiate a
AsynchronousCommandBus. |
| Modifier | Constructor and Description |
|---|---|
protected |
AsynchronousCommandBus(AsynchronousCommandBus.Builder builder)
Instantiate a
AsynchronousCommandBus based on the fields contained in the AsynchronousCommandBus.Builder. |
| Modifier and Type | Method and Description |
|---|---|
static AsynchronousCommandBus.Builder |
builder()
Instantiate a Builder to be able to create a
AsynchronousCommandBus. |
protected <C,R> void |
handle(CommandMessage<C> command,
MessageHandler<? super CommandMessage<?>> handler,
CommandCallback<? super C,? super R> callback)
Performs the actual handling logic.
|
void |
shutdown()
Shuts down the Executor used to asynchronously dispatch incoming commands.
|
dispatch, doDispatch, intercept, registerDispatchInterceptor, registerHandlerInterceptor, setRollbackConfiguration, subscribeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdispatchprotected AsynchronousCommandBus(AsynchronousCommandBus.Builder builder)
AsynchronousCommandBus based on the fields contained in the AsynchronousCommandBus.Builder.
Will assert that the TransactionManager, MessageMonitor, RollbackConfiguration and
Executor are not null, and will throw an AxonConfigurationException if any of them is
null.
builder - the AsynchronousCommandBus.Builder used to instantiate a AsynchronousCommandBus instancepublic static AsynchronousCommandBus.Builder builder()
AsynchronousCommandBus.
The TransactionManager is defaulted to a NoTransactionManager, the MessageMonitor is
defaulted to a NoOpMessageMonitor, RollbackConfiguration defaults to a
RollbackConfigurationType.UNCHECKED_EXCEPTIONS and the Executor defaults to a
Executors.newCachedThreadPool(). The defaultexecutor uses an AxonThreadFactory to create
threads with a sensible naming scheme. The TransactionManager, MessageMonitor, RollbackConfiguration and Executor
are hard requirements. Thus setting them to null will result in an
AxonConfigurationException.
AsynchronousCommandBusprotected <C,R> void handle(CommandMessage<C> command, MessageHandler<? super CommandMessage<?>> handler, CommandCallback<? super C,? super R> callback)
SimpleCommandBushandle in class SimpleCommandBusC - The type of payload of the commandR - The type of result expected from the command handlercommand - The actual command to handlehandler - The handler that must be invoked for this commandcallback - The callback to notify of the resultpublic void shutdown()
Executor provided
in the constructor does not implement ExecutorService, this method does nothing.Copyright © 2010–2018. All rights reserved.