Interface CommandBus

    • Method Detail

      • getInterceptors

        List<CommandBusInterceptor> getInterceptors()
        Returns an immutable list of interceptors
        Returns:
        Returns an immutable list of interceptors
      • addInterceptor

        CommandBus addInterceptor​(CommandBusInterceptor interceptor)
        Add a new interceptor
        Parameters:
        interceptor - the interceptor to add
        Returns:
        this bus instance
      • hasInterceptor

        boolean hasInterceptor​(CommandBusInterceptor interceptor)
        Guard method to test if the CommandBus already contains the interceptor
        Parameters:
        interceptor - the interceptor to check
        Returns:
        true if the CommandBus already contains the interceptor, otherwise false
      • removeInterceptor

        CommandBus removeInterceptor​(CommandBusInterceptor interceptor)
        Remove an interceptor
        Parameters:
        interceptor - the interceptor to remove
        Returns:
        this bus instance
      • addCommandHandler

        CommandBus addCommandHandler​(CommandHandler commandHandler)
        Add a new command handler.
        Parameters:
        commandHandler - the command handler to add
        Returns:
        this bus instance
      • removeCommandHandler

        CommandBus removeCommandHandler​(CommandHandler commandHandler)
        Remove a command handler.
        Parameters:
        commandHandler - the command handler to remove
        Returns:
        this bus instance
      • sendAsync

        <R,​C> reactor.core.publisher.Mono<R> sendAsync​(C command)
        The send command asynchronously and process the command on a Schedulers.boundedElastic() thread
        Type Parameters:
        R - the return type
        C - the command type
        Parameters:
        command - the command to send
        Returns:
        a Mono that will contain the result of the command processing (if any)
        Throws:
        MultipleCommandHandlersFoundException - If multiple CommandHandler claim that they can handle a given command
        NoCommandHandlerFoundException - If no CommandHandler's can handle the given command
      • sendAndDontWait

        <C> void sendAndDontWait​(C command)
        The send command asynchronously without waiting for the result of processing the Command.
        The command handler cannot return any value when invoked using this method.
        Type Parameters:
        C - the command type
        Parameters:
        command - the command to send
        Throws:
        MultipleCommandHandlersFoundException - If multiple CommandHandler claim that they can handle a given command
        NoCommandHandlerFoundException - If no CommandHandler's can handle the given command
      • sendAndDontWait

        <C> void sendAndDontWait​(C command,
                                 Duration delayMessageDelivery)
        The send command asynchronously without waiting for the result of processing the Command.
        The command handler cannot return any value when invoked using this method.
        Type Parameters:
        C - the command type
        Parameters:
        command - the command to send
        delayMessageDelivery - how long should we delay the command message sending
        Throws:
        MultipleCommandHandlersFoundException - If multiple CommandHandler claim that they can handle a given command
        NoCommandHandlerFoundException - If no CommandHandler's can handle the given command
      • hasCommandHandler

        boolean hasCommandHandler​(CommandHandler commandHandler)
        Guard method to test if the CommandBus already contains the commandHandler
        Parameters:
        commandHandler - the commandHandler to check
        Returns:
        true if the CommandBus already contains the commandHandler, otherwise false