Class AbstractCommandGateway
java.lang.Object
org.axonframework.commandhandling.gateway.AbstractCommandGateway
- Direct Known Subclasses:
DefaultCommandGateway
Abstract implementation of a CommandGateway, which handles the dispatch interceptors and retrying on failure. The
actual dispatching of commands is left to the subclasses.
- Since:
- 2.2
- Author:
- Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbstract Builder class to instantiateAbstractCommandGatewayimplementations. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate anAbstractCommandGatewaybased on the fields contained in theAbstractCommandGateway.Builder. -
Method Summary
Modifier and TypeMethodDescriptionReturns the CommandBus used by this gateway.protected <C> CommandMessage<? extends C> processInterceptors(CommandMessage<C> commandMessage) Invokes all the dispatch interceptors and returns the CommandMessage instance that should be dispatched.protected RegistrationregisterDispatchInterceptor(MessageDispatchInterceptor<? super CommandMessage<?>> interceptor) Registers a command dispatch interceptor within aCommandGateway.protected <C,R> void send(C command, CommandCallback<? super C, ? super R> callback) Sends the givencommand, and invokes thecallbackwhen the command is processed.protected voidsendAndForget(Object command) Dispatches a command without callback.
-
Constructor Details
-
AbstractCommandGateway
Instantiate anAbstractCommandGatewaybased on the fields contained in theAbstractCommandGateway.Builder.Will assert that the
CommandBusis notnulland throws anAxonConfigurationExceptionif it is.- Parameters:
builder- theAbstractCommandGateway.Builderused to instantiate aAbstractCommandGatewayinstance
-
-
Method Details
-
send
protected <C,R> void send(@Nonnull C command, @Nonnull CommandCallback<? super C, ? super R> callback) Sends the givencommand, and invokes thecallbackwhen the command is processed.- Type Parameters:
R- The type of response expected from the command- Parameters:
command- The command to dispatchcallback- The callback to notify with the processing result
-
sendAndForget
Dispatches a command without callback. When dispatching fails, since there is no callback, the command will not be retried.- Parameters:
command- The command to dispatch
-
registerDispatchInterceptor
protected Registration registerDispatchInterceptor(@Nonnull MessageDispatchInterceptor<? super CommandMessage<?>> interceptor) Registers a command dispatch interceptor within aCommandGateway.- Parameters:
interceptor- To intercept command messages- Returns:
- a registration which can be used to cancel the registration of given interceptor
-
processInterceptors
Invokes all the dispatch interceptors and returns the CommandMessage instance that should be dispatched.- Parameters:
commandMessage- The incoming command message- Returns:
- The command message to dispatch
-
getCommandBus
Returns the CommandBus used by this gateway. Should be used to monitoring or testing.- Returns:
- The CommandBus used by this gateway
-