|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.commandhandling.distributed.DistributedCommandBus
public class DistributedCommandBus
Implementation of a CommandBus
that is aware of multiple instances of a CommandBus working together to
spread load. Each "physical" CommandBus instance is considered a "segment" of a conceptual distributed CommandBus.
CommandBusConnector
to dispatch commands and replies to different
segments of the CommandBus. Depending on the implementation used, each segment may run in a different JVM.
Constructor Summary | |
---|---|
DistributedCommandBus(CommandBusConnector connector)
Initializes the command bus with the given connector and an AnnotationRoutingStrategy . |
|
DistributedCommandBus(CommandBusConnector connector,
RoutingStrategy routingStrategy)
Initializes the command bus with the given connector and routingStrategy . |
Method Summary | ||
---|---|---|
void |
dispatch(CommandMessage<?> command)
Dispatch the given command to the CommandHandler subscribed to that type of command . |
|
|
dispatch(CommandMessage<?> command,
CommandCallback<R> callback)
Dispatch the given command to the CommandHandler subscribed to that type of command . |
|
void |
setCommandDispatchInterceptors(Collection<CommandDispatchInterceptor> newDispatchInterceptors)
Sets the interceptors that intercept commands just prior to dispatching them. |
|
|
subscribe(String commandName,
CommandHandler<? super C> handler)
Subscribe the given handler to commands of type commandType . |
|
|
unsubscribe(String commandName,
CommandHandler<? super C> handler)
Unsubscribe the given handler to commands of type commandType . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DistributedCommandBus(CommandBusConnector connector)
connector
and an AnnotationRoutingStrategy
.
connector
- the connector that connects the different command bus segmentspublic DistributedCommandBus(CommandBusConnector connector, RoutingStrategy routingStrategy)
connector
and routingStrategy
. The
routingStrategy
is used to calculate a routing key for each dispatched command. For a given
configuration of segments, commands resulting in the same routing key are routed to the same segment.
connector
- the connector that connects the different command bus segmentsroutingStrategy
- the RoutingStrategy to define routing keys for each commandMethod Detail |
---|
public void dispatch(CommandMessage<?> command)
command
to the CommandHandler subscribed to that type of command
.
No
feedback is given about the status of the dispatching process. Implementations may return immediately after
asserting a valid handler is registered for the given command.
dispatch
in interface CommandBus
command
- The Command to dispatch
CommandDispatchException
- when an error occurs while dispatching the command to a segmentGenericCommandMessage.asCommandMessage(Object)
public <R> void dispatch(CommandMessage<?> command, CommandCallback<R> callback)
command
to the CommandHandler subscribed to that type of command
.
When the command is processed, on of the callback methods is called, depending on the result of the processing.
When the method returns, the only guarantee provided by the CommandBus implementation, is that the command has
been successfully received. Implementations are highly recommended to perform basic validation of the command
before returning from this method call.
Implementations must start a UnitOfWork when before dispatching the command, and either commit or rollback after
a successful or failed execution, respectively.
dispatch
in interface CommandBus
R
- The type of the expected resultcommand
- The Command to dispatchcallback
- The callback to invoke when command processing is complete
CommandDispatchException
- when an error occurs while dispatching the command to a segmentGenericCommandMessage.asCommandMessage(Object)
public <C> void subscribe(String commandName, CommandHandler<? super C> handler)
handler
to commands of type commandType
.
If a subscription already exists for the given type, the behavior is undefined. Implementations may throw an
Exception to refuse duplicate subscription or alternatively decide whether the existing or new
handler
gets the subscription.
In the DistributedCommandBus, the handler is subscribed to the local segment only.
subscribe
in interface CommandBus
C
- The Type of commandcommandName
- The name of the command to subscribe the handler tohandler
- The handler instance that handles the given type of commandpublic <C> boolean unsubscribe(String commandName, CommandHandler<? super C> handler)
handler
to commands of type commandType
. If the handler is not
currently assigned to that type of command, no action is taken.
In the DistributedCommandBus, the handler is unsubscribed from the local segment only.
unsubscribe
in interface CommandBus
C
- The Type of commandcommandName
- The name of the command the handler is subscribed tohandler
- The handler instance to unsubscribe from the CommandBus
true
of this handler is successfully unsubscribed, false
of the given
handler
was not the current handler for given commandType
.public void setCommandDispatchInterceptors(Collection<CommandDispatchInterceptor> newDispatchInterceptors)
newDispatchInterceptors
- The interceptors to intercepts commands with
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |