Class RecordingCommandBus
- All Implemented Interfaces:
DescribableComponent,CommandBus,CommandHandlerRegistry<CommandBus>
- Since:
- 1.1
- Author:
- Allard Buijze
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClears all the commands recorded by this Command Bus.voidClears all subscribed handlers on this command bus.voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.dispatch(CommandMessage command, ProcessingContext processingContext) Returns a list with all commands that have been dispatched by this command bus.Returns a Map will all Command Names and their Command Handler that have been subscribed to this command bus.booleanisSubscribed(CommandHandler commandHandler) Indicates whether the givencommandHandleris subscribed to this command bus.booleanisSubscribed(QualifiedName commandName, CommandHandler commandHandler) Indicates whether the givencommandHandleris subscribed to commands of the givencommandTypeon this command bus.voidsetCallbackBehavior(CallbackBehavior callbackBehavior) Sets the instance that defines the behavior of the Command Bus when a command is dispatched with a callback.subscribe(QualifiedName name, CommandHandler handler) 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.CommandHandlerRegistry
subscribe, subscribe
-
Constructor Details
-
RecordingCommandBus
public RecordingCommandBus()
-
-
Method Details
-
dispatch
public CompletableFuture<CommandResultMessage> dispatch(@Nonnull CommandMessage command, @Nullable ProcessingContext processingContext) Description copied from interface:CommandBusDispatch the givencommandto thecommand handlersubscribedto the givencommand's name. The name is typically deferred from theMessage.type(), which contains aMessageType.qualifiedName().- Specified by:
dispatchin interfaceCommandBus- Parameters:
command- The command to dispatch.processingContext- The processing context under which the command is being published (can benull).- Returns:
- The
CompletableFutureproviding the result of the command, once finished.
-
subscribe
Description copied from interface:CommandHandlerRegistrySubscribe the givenhandlerforcommandsof the givenname.If a subscription already exists for the
name, the behavior is undefined. Implementations may throw an exception to refuse duplicate subscription or alternatively decide whether the existing or newhandlergets the subscription.- Specified by:
subscribein interfaceCommandHandlerRegistry<CommandBus>- Parameters:
name- The name the givencommandHandlercan handle.handler- The handler instance that handlescommandsfor the given name.- Returns:
- This registry for fluent interfacing.
-
clearCommands
public void clearCommands()Clears all the commands recorded by this Command Bus. -
clearSubscriptions
public void clearSubscriptions()Clears all subscribed handlers on this command bus. -
isSubscribed
Indicates whether the givencommandHandleris subscribed to this command bus.- Parameters:
commandHandler- The command handler to verify the subscription for- Returns:
trueif the handler is subscribed, otherwisefalse.
-
isSubscribed
Indicates whether the givencommandHandleris subscribed to commands of the givencommandTypeon this command bus.- Parameters:
commandName- The name of the command to verify the subscription forcommandHandler- The command handler to verify the subscription for- Returns:
trueif the handler is subscribed, otherwisefalse.
-
getSubscriptions
Returns a Map will all Command Names and their Command Handler that have been subscribed to this command bus.- Returns:
- a Map will all Command Names and their Command Handler
-
getDispatchedCommands
Returns a list with all commands that have been dispatched by this command bus.- Returns:
- a list with all commands that have been dispatched
-
setCallbackBehavior
Sets the instance that defines the behavior of the Command Bus when a command is dispatched with a callback.- Parameters:
callbackBehavior- The instance deciding to how the callback should be invoked.
-
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.
-