Class AxonServerCommandBus
- All Implemented Interfaces:
org.axonframework.commandhandling.CommandBus,org.axonframework.lifecycle.Lifecycle,org.axonframework.messaging.Distributed<org.axonframework.commandhandling.CommandBus>,org.axonframework.messaging.MessageDispatchInterceptorSupport<org.axonframework.commandhandling.CommandMessage<?>>,org.axonframework.messaging.MessageHandlerInterceptorSupport<org.axonframework.commandhandling.CommandMessage<?>>
CommandBus implementation that connects to Axon Server to submit and receive commands and command
responses. Delegates incoming commands to the provided localSegment.- Since:
- 4.0
- Author:
- Marc Gathier
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate anAxonServerCommandBus.Nested classes/interfaces inherited from interface org.axonframework.lifecycle.Lifecycle
org.axonframework.lifecycle.Lifecycle.LifecycleHandler, org.axonframework.lifecycle.Lifecycle.LifecycleRegistry -
Constructor Summary
ConstructorsConstructorDescriptionInstantiate aAxonServerCommandBusbased on the fields contained in theAxonServerCommandBus.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic AxonServerCommandBus.Builderbuilder()Instantiate a Builder to be able to create anAxonServerCommandBus.Disconnect the command bus for receiving commands from Axon Server, by unsubscribing all registered command handlers.<C> voiddispatch(org.axonframework.commandhandling.CommandMessage<C> command) <C,R> void dispatch(org.axonframework.commandhandling.CommandMessage<C> commandMessage, org.axonframework.commandhandling.CommandCallback<? super C, ? super R> commandCallback) org.axonframework.commandhandling.CommandBusorg.axonframework.common.RegistrationregisterDispatchInterceptor(org.axonframework.messaging.MessageDispatchInterceptor<? super org.axonframework.commandhandling.CommandMessage<?>> dispatchInterceptor) org.axonframework.common.RegistrationregisterHandlerInterceptor(org.axonframework.messaging.MessageHandlerInterceptor<? super org.axonframework.commandhandling.CommandMessage<?>> handlerInterceptor) voidregisterLifecycleHandlers(org.axonframework.lifecycle.Lifecycle.LifecycleRegistry handle) Shutdown the command bus asynchronously for dispatching commands to Axon Server.voidstart()Start the Axon ServerCommandBusimplementation.org.axonframework.common.Registrationsubscribe(String commandName, org.axonframework.messaging.MessageHandler<? super org.axonframework.commandhandling.CommandMessage<?>> messageHandler)
-
Constructor Details
-
AxonServerCommandBus
Instantiate aAxonServerCommandBusbased on the fields contained in theAxonServerCommandBus.Builder.- Parameters:
builder- theAxonServerCommandBus.Builderused to instantiate aAxonServerCommandBusinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create anAxonServerCommandBus.The
CommandPriorityCalculatoris defaulted toCommandPriorityCalculator.defaultCommandPriorityCalculator(), theTargetContextResolverdefaults to a lambda returning theAxonServerConfiguration.getContext()as the context and theCommandBusSpanFactorydefaults to aDefaultCommandBusSpanFactorybacked by aNoOpSpanFactory. TheExecutorServiceBuilderdefaults toExecutorServiceBuilder.defaultCommandExecutorServiceBuilder(). TheAxonServerConnectionManager, theAxonServerConfiguration, the localCommandBus,Serializerand theRoutingStrategyare a hard requirements and as such should be provided.- Returns:
- a Builder to be able to create a
AxonServerCommandBus
-
registerLifecycleHandlers
public void registerLifecycleHandlers(@Nonnull org.axonframework.lifecycle.Lifecycle.LifecycleRegistry handle) - Specified by:
registerLifecycleHandlersin interfaceorg.axonframework.lifecycle.Lifecycle
-
start
public void start()Start the Axon ServerCommandBusimplementation. -
dispatch
public <C> void dispatch(@Nonnull org.axonframework.commandhandling.CommandMessage<C> command) - Specified by:
dispatchin interfaceorg.axonframework.commandhandling.CommandBus
-
dispatch
public <C,R> void dispatch(@Nonnull org.axonframework.commandhandling.CommandMessage<C> commandMessage, @Nonnull org.axonframework.commandhandling.CommandCallback<? super C, ? super R> commandCallback) - Specified by:
dispatchin interfaceorg.axonframework.commandhandling.CommandBus
-
subscribe
public org.axonframework.common.Registration subscribe(@Nonnull String commandName, @Nonnull org.axonframework.messaging.MessageHandler<? super org.axonframework.commandhandling.CommandMessage<?>> messageHandler) - Specified by:
subscribein interfaceorg.axonframework.commandhandling.CommandBus
-
localSegment
public org.axonframework.commandhandling.CommandBus localSegment()- Specified by:
localSegmentin interfaceorg.axonframework.messaging.Distributed<org.axonframework.commandhandling.CommandBus>
-
registerHandlerInterceptor
public org.axonframework.common.Registration registerHandlerInterceptor(@Nonnull org.axonframework.messaging.MessageHandlerInterceptor<? super org.axonframework.commandhandling.CommandMessage<?>> handlerInterceptor) - Specified by:
registerHandlerInterceptorin interfaceorg.axonframework.messaging.MessageHandlerInterceptorSupport<org.axonframework.commandhandling.CommandMessage<?>>
-
registerDispatchInterceptor
public org.axonframework.common.Registration registerDispatchInterceptor(@Nonnull org.axonframework.messaging.MessageDispatchInterceptor<? super org.axonframework.commandhandling.CommandMessage<?>> dispatchInterceptor) - Specified by:
registerDispatchInterceptorin interfaceorg.axonframework.messaging.MessageDispatchInterceptorSupport<org.axonframework.commandhandling.CommandMessage<?>>
-
disconnect
Disconnect the command bus for receiving commands from Axon Server, by unsubscribing all registered command handlers. This shutdown operation is performed in thePhase.INBOUND_COMMAND_CONNECTORphase.This method will wait for in-progress command handlers to complete, up to the configured
commandInProgressAwaitduration. If handlers do not complete within this time, they will be cancelled. -
shutdownDispatching
Shutdown the command bus asynchronously for dispatching commands to Axon Server. This process will wait for dispatched commands which have not received a response yet. This shutdown operation is performed in thePhase.OUTBOUND_COMMAND_CONNECTORSphase.- Returns:
- a completable future which is resolved once all command dispatching activities are completed
-