Class DelegatingCommandBusConnector
- All Implemented Interfaces:
DescribableComponent,CommandBusConnector
- Direct Known Subclasses:
PayloadConvertingCommandBusConnector
CommandBusConnector implementation that wraps another CommandBusConnector and delegates all calls
to it. This can be used to add additional functionality through decoration to a CommandBusConnector without
having to implement all methods again.- Since:
- 5.0.0
- Author:
- Mitchell Herrijgers
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.messaging.commandhandling.distributed.CommandBusConnector
CommandBusConnector.Handler, CommandBusConnector.ResultCallback -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInitialize the WrappedConnector to delegate all calls to the givendelegate. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.dispatch(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.
-
Field Details
-
delegate
-
-
Constructor Details
-
DelegatingCommandBusConnector
Initialize the WrappedConnector to delegate all calls to the givendelegate.- Parameters:
delegate- TheCommandBusConnectorto delegate all calls to.
-
-
Method Details
-
dispatch
@Nonnull public CompletableFuture<CommandResultMessage> dispatch(@Nonnull CommandMessage command, @Nullable ProcessingContext processingContext) Description copied from interface:CommandBusConnectorDispatches the givencommandto the appropriate command bus, which may be local or remote.- Specified by:
dispatchin interfaceCommandBusConnector- 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
Description copied from interface:CommandBusConnectorSubscribes to a command with the givencommandNameand aloadFactor.- Specified by:
subscribein interfaceCommandBusConnector- 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
Description copied from interface:CommandBusConnectorUnsubscribes from a command with the givencommandName.- Specified by:
unsubscribein interfaceCommandBusConnector- Parameters:
commandName- TheQualifiedNameof the command to unsubscribe from.- Returns:
trueif the unsubscription was successful,falseotherwise.
-
onIncomingCommand
Description copied from interface:CommandBusConnectorRegisters 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.- Specified by:
onIncomingCommandin interfaceCommandBusConnector- Parameters:
handler- ABiConsumerthat takes aCommandMessageand aCommandBusConnector.ResultCallback.
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-