public class AxonServerCommandBus extends Object implements CommandBus
Modifier and Type | Class and Description |
---|---|
protected class |
AxonServerCommandBus.CommandRouterSubscriber |
Constructor and Description |
---|
AxonServerCommandBus(AxonServerConnectionManager axonServerConnectionManager,
AxonServerConfiguration configuration,
CommandBus localSegment,
Serializer serializer,
RoutingStrategy routingStrategy) |
AxonServerCommandBus(AxonServerConnectionManager axonServerConnectionManager,
AxonServerConfiguration configuration,
CommandBus localSegment,
Serializer serializer,
RoutingStrategy routingStrategy,
CommandPriorityCalculator priorityCalculator) |
Modifier and Type | Method and Description |
---|---|
void |
disconnect()
Disconnect the command bus from the Axon Server.
|
<C> void |
dispatch(CommandMessage<C> command)
Dispatch the given
command to the CommandHandler subscribed to the given command 's name. |
<C,R> void |
dispatch(CommandMessage<C> commandMessage,
CommandCallback<? super C,? super R> commandCallback)
Dispatch the given
command to the CommandHandler subscribed to the given command 's name. |
Registration |
registerDispatchInterceptor(MessageDispatchInterceptor<? super CommandMessage<?>> dispatchInterceptor)
Register the given DispatchInterceptor.
|
Registration |
registerHandlerInterceptor(MessageHandlerInterceptor<? super CommandMessage<?>> handlerInterceptor)
Register the given
handlerInterceptor . |
Registration |
subscribe(String s,
MessageHandler<? super CommandMessage<?>> messageHandler)
Subscribe the given
handler to commands with the given commandName . |
public AxonServerCommandBus(AxonServerConnectionManager axonServerConnectionManager, AxonServerConfiguration configuration, CommandBus localSegment, Serializer serializer, RoutingStrategy routingStrategy)
public AxonServerCommandBus(AxonServerConnectionManager axonServerConnectionManager, AxonServerConfiguration configuration, CommandBus localSegment, Serializer serializer, RoutingStrategy routingStrategy, CommandPriorityCalculator priorityCalculator)
axonServerConnectionManager
- creates connection to AxonServer platformconfiguration
- contains client and component names used to identify the application in AxonServerlocalSegment
- handles incoming commandsserializer
- serializer/deserializer for command requests and responsesroutingStrategy
- determines routing key based on command messagepriorityCalculator
- calculates the request priority based on the content and adds it to the requestpublic <C> void dispatch(CommandMessage<C> command)
CommandBus
command
to the CommandHandler subscribed to the given command
's name.
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
C
- The payload type of the command to dispatchcommand
- The Command to dispatchGenericCommandMessage.asCommandMessage(Object)
public <C,R> void dispatch(CommandMessage<C> commandMessage, CommandCallback<? super C,? super R> commandCallback)
CommandBus
command
to the CommandHandler subscribed to the given command
's name.
When the command is processed, one of the callback's 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
C
- The payload type of the command to dispatchR
- The type of the expected resultcommandMessage
- The Command to dispatchcommandCallback
- The callback to invoke when command processing is completeGenericCommandMessage.asCommandMessage(Object)
public Registration subscribe(String s, MessageHandler<? super CommandMessage<?>> messageHandler)
CommandBus
handler
to commands with the given commandName
.
If a subscription already exists for the given name, 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.subscribe
in interface CommandBus
s
- The name of the command to subscribe the handler tomessageHandler
- The handler instance that handles the given type of commandhandler
. When unsubscribed it will no longer receive commands.public Registration registerHandlerInterceptor(MessageHandlerInterceptor<? super CommandMessage<?>> handlerInterceptor)
MessageHandlerInterceptorSupport
handlerInterceptor
. After registration, the interceptor will be invoked for each
handled Message on the messaging component that it was registered to, prior to invoking the message's handler.registerHandlerInterceptor
in interface MessageHandlerInterceptorSupport<CommandMessage<?>>
handlerInterceptor
- The interceptor to registerpublic void disconnect()
public Registration registerDispatchInterceptor(MessageDispatchInterceptor<? super CommandMessage<?>> dispatchInterceptor)
MessageDispatchInterceptorSupport
registerDispatchInterceptor
in interface MessageDispatchInterceptorSupport<CommandMessage<?>>
dispatchInterceptor
- The interceptor to registerCopyright © 2010–2018. All rights reserved.