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.Constructor and Description |
---|
AsynchronousCommandBus()
Initialize the AsynchronousCommandBus, using a Cached Thread Pool.
|
AsynchronousCommandBus(Executor executor)
Initialize the AsynchronousCommandBus using the given
executor . |
Modifier and Type | Method and Description |
---|---|
protected <R> void |
doDispatch(CommandMessage<?> command,
CommandCallback<R> callback)
Performs the actual dispatching logic.
|
void |
shutdown()
Shuts down the Executor used to asynchronously dispatch incoming commands.
|
dispatch, dispatch, intercept, setDispatchInterceptors, setHandlerInterceptors, setRollbackConfiguration, setSubscriptions, setTransactionManager, setUnitOfWorkFactory, subscribe, unsubscribe
public AsynchronousCommandBus()
public AsynchronousCommandBus(Executor executor)
executor
.executor
- The executor that processes Command dispatching threadsprotected <R> void doDispatch(CommandMessage<?> command, CommandCallback<R> callback)
SimpleCommandBus
doDispatch
in class SimpleCommandBus
R
- The type of result expected from the command handlercommand
- The actual command to dispatch to the handlercallback
- The callback to notify of the resultpublic void shutdown()
Executor
provided
in the constructor does not implement ExecutorService
, this method does nothing.Copyright © 2010-2014. All Rights Reserved.