Interface CommandBusConnector
- All Superinterfaces:
DescribableComponent
- All Known Implementing Classes:
AxonServerCommandBusConnector,DelegatingCommandBusConnector,PayloadConvertingCommandBusConnector
The
CommandBusConnector interface defines the contract for connecting multiple CommandBus instances.
It allows for the dispatching of commands across different command bus instances, whether they are local or remote.
One connector can be wrapped with another through the DelegatingCommandBusConnector, upon which more
functionality can be added, such as payload conversion or conversion.
- Since:
- 2.0.0
- Author:
- Allard Buijze, Mitchell Herrijgers, Steven van Beelen
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA functional interface representing a handler for incoming command messages.static interfaceA callback interface for handling the result of command processing. -
Method Summary
Modifier and TypeMethodDescriptiondispatch(CommandMessage command, ProcessingContext processingContext) Dispatches the givencommandto the appropriate command bus, which may be local or remote.voidRegisters a handler that will be called when an incoming command is received.subscribe(QualifiedName commandName, int loadFactor) Subscribes to a command with the givencommandNameand aloadFactor.booleanunsubscribe(QualifiedName commandName) Unsubscribes from a command with the givencommandName.Methods inherited from interface org.axonframework.common.infra.DescribableComponent
describeTo
-
Method Details
-
dispatch
@Nonnull CompletableFuture<CommandResultMessage> dispatch(@Nonnull CommandMessage command, @Nullable ProcessingContext processingContext) Dispatches the givencommandto the appropriate command bus, which may be local or remote.- Parameters:
command- The command message to dispatch.processingContext- The processing context for the command.- Returns:
- A
CompletableFuturethat will complete with the result of the command handling.
-
subscribe
Subscribes to a command with the givencommandNameand aloadFactor.- Parameters:
commandName- TheQualifiedNameof the command to subscribe to.loadFactor- The load factor for the command, which can be used to control the distribution of command handling across multiple instances. The load factor should be a positive integer.- Returns:
- A
CompletableFuturethat completes successfully when this connector subscribed to the givencommandNamewith the givenloadFactor.
-
unsubscribe
Unsubscribes from a command with the givencommandName.- Parameters:
commandName- TheQualifiedNameof the command to unsubscribe from.- Returns:
trueif the unsubscription was successful,falseotherwise.
-
onIncomingCommand
Registers a handler that will be called when an incoming command is received. The handler should process the command and call the providedResultCallbackto indicate success or failure.- Parameters:
handler- ABiConsumerthat takes aCommandMessageand aCommandBusConnector.ResultCallback.
-