Class PayloadConvertingCommandBusConnector
- All Implemented Interfaces:
DescribableComponent,CommandBusConnector
byte[] or another serialized form.- Since:
- 5.0.0
- Author:
- Allard Buijze
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.messaging.commandhandling.distributed.CommandBusConnector
CommandBusConnector.Handler, CommandBusConnector.ResultCallback -
Field Summary
Fields inherited from class org.axonframework.messaging.commandhandling.distributed.DelegatingCommandBusConnector
delegate -
Constructor Summary
ConstructorsConstructorDescriptionPayloadConvertingCommandBusConnector(CommandBusConnector delegate, MessageConverter converter, Class<?> targetType) Initialize thePayloadConvertingConnectorto use givenconverterto convert each Message's payload intotargetTypebefore passing it to 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.Methods inherited from class org.axonframework.messaging.commandhandling.distributed.DelegatingCommandBusConnector
subscribe, unsubscribe
-
Constructor Details
-
PayloadConvertingCommandBusConnector
public PayloadConvertingCommandBusConnector(@Nonnull CommandBusConnector delegate, @Nonnull MessageConverter converter, @Nonnull Class<?> targetType) Initialize thePayloadConvertingConnectorto use givenconverterto convert each Message's payload intotargetTypebefore passing it to givendelegate.- Parameters:
delegate- The delegate to pass converted messages to.converter- The converter to use to convert each Message's payload.targetType- The desired representation of forwarded Message's payload.
-
-
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- Overrides:
dispatchin classDelegatingCommandBusConnector- 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.
-
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- Overrides:
onIncomingCommandin classDelegatingCommandBusConnector- 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- Overrides:
describeToin classDelegatingCommandBusConnector- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-