Class TracingCommandBusConnector
- All Implemented Interfaces:
CommandBusConnector,DescribableComponent
CommandBusConnector.
Opens a producer span around the send leg (dispatch(CommandMessage, ProcessingContext)) and a consumer
span around the receive leg (onIncomingCommand handler invocation). These connector legs nest between the
local bus dispatch / handle spans produced by TracingCommandBus and become observable only over a real
transport -- in-process tests with no connector wiring will not see them.
This decorator is registered by DistributedTracingConfigurationEnhancer; it is never instantiated directly
by applications.
- Since:
- 5.3.0
- Author:
- Mateusz Nowak
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.axoniq.framework.messaging.commandhandling.distributed.CommandBusConnector
CommandBusConnector.Handler, CommandBusConnector.ResultCallback -
Constructor Summary
ConstructorsConstructorDescriptionTracingCommandBusConnector(CommandBusConnector delegate, SpanFactory spanFactory) Initializes a tracingCommandBusConnectorwrapping the givendelegate, obtaining spans from the givenspanFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.dispatch(CommandMessage command, @Nullable 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.
-
Constructor Details
-
TracingCommandBusConnector
Initializes a tracingCommandBusConnectorwrapping the givendelegate, obtaining spans from the givenspanFactory.- Parameters:
delegate- the connector to delegate tospanFactory- the factory producing the tracing spans
-
-
Method Details
-
dispatch
public CompletableFuture<CommandResultMessage> dispatch(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.
-