Class ContextAwareCommandDispatcher
- All Implemented Interfaces:
DescribableComponent,CommandDispatcher
CommandDispatcher that publishes commands to a CommandGateway in a predefined
ProcessingContext.
Any commands dispatched through this CommandDispatcher occur within the context this dispatcher was
created with. You can construct one through the
invalid reference
CommandDispatcher#forContext(ProcessingContext, Configuration)
- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Field Summary
Fields inherited from interface org.axonframework.messaging.commandhandling.gateway.CommandDispatcher
RESOURCE_KEY -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.Sends the givencommandand returns aCommandResultimmediately, without waiting for the command to execute.Sends the givencommandwith the givenmetadataand returns aCommandResultimmediately, without waiting for the command to execute.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.commandhandling.gateway.CommandDispatcher
send
-
Method Details
-
send
Description copied from interface:CommandDispatcherSends the givencommandand returns aCommandResultimmediately, without waiting for the command to execute.The caller will therefore not receive any immediate feedback on the
command'sexecution. Instead, hooks can be added to the returnedCommandResultto react on success or failure of command execution. A shorthand to retrieve aCompletableFutureis available through theCommandResult.getResultMessage()operation.Note that this operation expects the
The givenCommandBusto use new threads for command execution.commandis wrapped as the payload of theCommandMessagethat is eventually posted on theCommandBus, unless thecommandalready implementsMessage. In that case, aCommandMessageis constructed from that message's payload andMetadata.- Specified by:
sendin interfaceCommandDispatcher- Parameters:
command- The command payload orCommandMessageto send.- Returns:
- A command result success and failure hooks can be registered. The
CommandResult.getResultMessage()serves as a shorthand to retrieve the response.
-
send
Description copied from interface:CommandDispatcherSends the givencommandwith the givenmetadataand returns aCommandResultimmediately, without waiting for the command to execute.The caller will therefore not receive any immediate feedback on the
command'sexecution. Instead, hooks can be added to the returnedCommandResultto react on success or failure of command execution. A shorthand to retrieve aCompletableFutureis available through theCommandResult.getResultMessage()operation.Note that this operation expects the
The givenCommandBusto use new threads for command execution.commandandmetadataare wrapped as the payload of theCommandMessagethat is eventually posted on theCommandBus, unless thecommandalready implementsMessage. In that case, aCommandMessageis constructed from that message's payload andMetadata. The providedmetadatais attached afterward in this case.- Specified by:
sendin interfaceCommandDispatcher- Parameters:
command- The command payload orCommandMessageto send.metadata- Metadata that must be registered with thecommand.- Returns:
- A command result success and failure hooks can be registered. The
CommandResult.getResultMessage()serves as a shorthand to retrieve the response.
-
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.
-