class CommandService implements AxonServerClientService {

    public void dispatch(byte[] command, StreamObserver<SerializedCommandResponse> responseObserver) {
        SerializedCommand request = new SerializedCommand(command);
        String clientId = request.wrapped().getClientId();
        if (logger.isTraceEnabled()) {
            logger.trace("{}: Received command: {}", clientId, request.wrapped().getName());
        }
        try {
            commandDispatcher.dispatch(contextProvider.getContext(), request, commandResponse -> safeReply(clientId,
                                                                                                           commandResponse,
                                                                                                           responseObserver),
                                       false);
        } catch (Exception ex) {
            logger.warn("Dispatching failed with unexpected error", ex);
            responseObserver.onError(GrpcExceptionBuilder.build(ex));
        }
    }

    public  CommandService(Topology topology,
                          CommandDispatcher commandDispatcher,
                          ContextProvider contextProvider,
                          ClientIdRegistry clientIdRegistry,
                          ApplicationEventPublisher eventPublisher,
                          @Qualifier("commandInstructionAckSource")
                                  InstructionAckSource<SerializedCommandProviderInbound> instructionAckSource);

}