Class SpringCloudCommandController

java.lang.Object
io.axoniq.framework.springcloud.command.SpringCloudCommandController

@RestController @RequestMapping("${axon.springcloud.command-endpoint:/axoniq-springcloud/command}") public class SpringCloudCommandController extends Object
Receives commands sent by other members of the cluster over HTTP.

Every member must expose this endpoint under the same path, since that is how members reach each other; the path is the value of the axon.springcloud.command-endpoint property, defaulting to DEFAULT_COMMAND_ENDPOINT. This controller is registered by the Spring Boot autoconfiguration.

Returning a CompletableFuture puts the request into Spring MVC's asynchronous handling, releasing the container thread while the command is processed on the command bus's own executor. That matters because a member receiving commands has no reason to tie up one container thread per command in flight.

Since:
5.4.0
Author:
Allard Buijze
  • Field Details

    • DEFAULT_COMMAND_ENDPOINT

      public static final String DEFAULT_COMMAND_ENDPOINT
      The path commands are received under when none is configured.
      See Also:
  • Constructor Details

    • SpringCloudCommandController

      public SpringCloudCommandController(IncomingCommandInvoker invoker)
      Constructs a SpringCloudCommandController handing received commands to the given invoker.
      Parameters:
      invoker - the component invoking this application's local command handler
  • Method Details

    • receiveCommand

      @PostMapping public CompletableFuture<CommandDispatchReply> receiveCommand(@RequestBody CommandDispatchRequest request)
      Handles the given request, sent by another member of the cluster.

      Answers with 200 OK whether handling succeeded or failed; a failure is reported in the body of the reply. See CommandDispatchReply for why.

      Parameters:
      request - the command sent by another member
      Returns:
      a future completing with the outcome of handling the command