Interface ICommandService


public interface ICommandService
A Command Service API of a csw component. This model provides method based APIs for command interactions with a component.
  • Method Details

    • oneway

      Send a command as a Oneway and get a CommandResponse.OnewayResponse as a Future. The CommandResponse can be a response of validation (Accepted, Invalid) or a Locked response.

      Parameters:
      controlCommand - the ControlCommand payload
      Returns:
      a CommandResponse as a Future value
    • onewayAndMatch

      CompletableFuture<CommandResponse.MatchingResponse> onewayAndMatch(ControlCommand controlCommand, StateMatcher stateMatcher)
      Submit a command and match the published state from the component using a StateMatcher. If the match is successful a Completed response is provided as a future. In case of a failure or unmatched state, Error CommandResponse is provided as a Future.

      Parameters:
      controlCommand - the ControlCommand payload
      stateMatcher - the StateMatcher implementation for matching received state against a demand state
      Returns:
      a MatchingResponse as a Future value
    • query

      Query for the result of a long running command which was sent as Submit to get a CommandResponse.SubmitResponse as a Future

      Parameters:
      commandRunId - the runId of the command for which response is required
      Returns:
      a CommandResponse as a Future value
    • queryFinal

      CompletableFuture<CommandResponse.SubmitResponse> queryFinal(Id commandRunId, akka.util.Timeout timeout)
      Query for the final result of a long running command which was sent as Submit to get a CommandResponse.SubmitResponse as a Future

      Parameters:
      commandRunId - the runId of the command for which response is required
      timeout - (undocumented)
      Returns:
      a CommandResponse as a Future value
    • submit

      Submit a command and return after first phase. If it returns as Started get a final CommandResponse.SubmitResponse as a Future with queryFinal.

      Parameters:
      controlCommand - the ControlCommand payload
      Returns:
      a CommandResponse as a Future value
    • submitAllAndWait

      CompletableFuture<List<CommandResponse.SubmitResponse>> submitAllAndWait(List<ControlCommand> submitCommands, akka.util.Timeout timeout)
      Submit multiple commands and get a Source of CommandResponse.SubmitResponse for all commands. The CommandResponse can be a response of validation (Accepted, Invalid) or a final Response. In case of response as Accepted, final CommandResponse can be obtained by using subscribe API.

      Parameters:
      submitCommands - the set of ControlCommand payloads
      timeout - (undocumented)
      Returns:
      a Source of CommandResponse as a stream of CommandResponses for all commands
    • submitAndWait

      CompletableFuture<CommandResponse.SubmitResponse> submitAndWait(ControlCommand controlCommand, akka.util.Timeout timeout)
      Submit a command and wait for the final result if it was successfully validated as Started to get a final CommandResponse.SubmitResponse as a Future

      Parameters:
      controlCommand - the ControlCommand payload
      timeout - (undocumented)
      Returns:
      a CommandResponse as a Future value
    • subscribeCurrentState

      akka.stream.javadsl.Source<CurrentState,msocket.api.Subscription> subscribeCurrentState()
      Subscribe to all the current states of a component corresponding to the AkkaLocation of the component

      Returns:
      a stream of current states with Subscription as the materialized value which can be used to stop the subscription
    • subscribeCurrentState

      akka.stream.javadsl.Source<CurrentState,msocket.api.Subscription> subscribeCurrentState(Set<StateName> names)
      Subscribe to the current state of a component corresponding to the AkkaLocation of the component

      Parameters:
      names - subscribe to states which have any of the provided value for name. If no states are provided, all the current states will be received.
      Returns:
      a stream of current states with Subscription as the materialized value which can be used to stop the subscription
    • subscribeCurrentState

      msocket.api.Subscription subscribeCurrentState(Consumer<CurrentState> callback)
      Subscribe to the current state of a component corresponding to the AkkaLocation of the component

      Note that callbacks are not thread-safe on the JVM. If you are doing side effects/mutations inside the callback, you should ensure that it is done in a thread-safe way inside an actor.

      Parameters:
      callback - the action to be applied on the CurrentState element received as a result of subscription
      Returns:
      a Subscription to stop the subscription
    • subscribeCurrentState

      msocket.api.Subscription subscribeCurrentState(Set<StateName> names, Consumer<CurrentState> callback)
      Subscribe to the current state of a component corresponding to the AkkaLocation of the component

      Note that callbacks are not thread-safe on the JVM. If you are doing side effects/mutations inside the callback, you should ensure that it is done in a thread-safe way inside an actor.

      Parameters:
      names - subscribe to only those states which have any of the the provided value for name
      callback - the action to be applied on the CurrentState element received as a result of subscription
      Returns:
      a Subscription to stop the subscription
    • validate

      Send a Validate command and get ValidateResponse as a Future. The ValidateResponse can be of type Accepted, Invalid or Locked.

      Parameters:
      controlCommand - the ControlCommand payload
      Returns:
      a ValidateResponse as a Future value