@Test void dispatchWhenChannelThrowsAnException() throws InterruptedException { CommandMessage<String> commandMessage = new GenericCommandMessage<>("this is the payload"); CountDownLatch waiter = new CountDownLatch(1); AtomicBoolean failure = new AtomicBoolean(false); AtomicReference<Throwable> throwable = new AtomicReference<>(); when(axonServerConnectionManager.getConnection(anyString())).thenReturn(mockConnection); when(mockCommandChannel.sendCommand(any())).thenThrow(new RuntimeException("oops")); testSubject.dispatch(commandMessage, (CommandCallback<String, String>) (cm, result) -> { if (result.isExceptional()) { failure.set(true); throwable.set(result.exceptionResult()); } waiter.countDown(); }); waiter.await(); assertTrue(failure.get()); assertEquals(AxonServerCommandDispatchException.class, throwable.get().getClass()); assertEquals(ErrorCode.COMMAND_DISPATCH_ERROR.errorCode(), ((AxonServerCommandDispatchException) throwable.get()).getErrorCode()); verify(targetContextResolver).resolveContext(commandMessage); verify(axonServerConnectionManager).getConnection(BOUNDED_CONTEXT); }
@Override public <C> void dispatch(CommandMessage<C> command) { dispatch(command, defaultCommandCallback); }
AxonServerCommandBus implements CommandBus, Distributed<CommandBus> { @Override public <C> void dispatch(CommandMessage<C> command) { dispatch(command, defaultCommandCallback); } }
AxonServerCommandBus implements CommandBus, Distributed<CommandBus> { @Override public <C> void dispatch(CommandMessage<C> command) { dispatch(command, defaultCommandCallback); } AxonServerCommandBus(Builder builder); }
AxonServerCommandBus implements CommandBus, Distributed<CommandBus> { @Override public <C> void dispatch(CommandMessage<C> command) { dispatch(command, defaultCommandCallback); } AxonServerCommandBus(Builder builder); static Builder builder(); @StartHandler(phase = Phase.INBOUND_COMMAND_CONNECTOR) void start(); @Override void dispatch(CommandMessage<C> command); @Override void dispatch(CommandMessage<C> commandMessage,
                                CommandCallback<? super C, ? super R> commandCallback); @Override Registration subscribe(String commandName, MessageHandler<? super CommandMessage<?>> messageHandler); @Override CommandBus localSegment(); @Override Registration registerHandlerInterceptor(
            MessageHandlerInterceptor<? super CommandMessage<?>> handlerInterceptor); @Override Registration registerDispatchInterceptor(
            MessageDispatchInterceptor<? super CommandMessage<?>> dispatchInterceptor); @ShutdownHandler(phase = Phase.INBOUND_COMMAND_CONNECTOR) CompletableFuture<Void> disconnect(); @ShutdownHandler(phase = Phase.OUTBOUND_COMMAND_CONNECTORS) CompletableFuture<Void> shutdownDispatching(); }
AxonServerCommandBus implements CommandBus, Distributed<CommandBus> { @Override public <C> void dispatch(CommandMessage<C> command) { dispatch(command, defaultCommandCallback); } AxonServerCommandBus(Builder builder); static Builder builder(); @StartHandler(phase = Phase.INBOUND_COMMAND_CONNECTOR) void start(); @Override void dispatch(CommandMessage<C> command); @Override void dispatch(CommandMessage<C> commandMessage,
                                CommandCallback<? super C, ? super R> commandCallback); @Override Registration subscribe(String commandName, MessageHandler<? super CommandMessage<?>> messageHandler); @Override CommandBus localSegment(); @Override Registration registerHandlerInterceptor(
            MessageHandlerInterceptor<? super CommandMessage<?>> handlerInterceptor); @Override Registration registerDispatchInterceptor(
            MessageDispatchInterceptor<? super CommandMessage<?>> dispatchInterceptor); @ShutdownHandler(phase = Phase.INBOUND_COMMAND_CONNECTOR) CompletableFuture<Void> disconnect(); @ShutdownHandler(phase = Phase.OUTBOUND_COMMAND_CONNECTORS) CompletableFuture<Void> shutdownDispatching();  }