Source:
private synchronized void startInstructionStream(String context, String name, ClientIdentification clientIdentification) { logger.debug("Start instruction stream to node for context [{}]", name, context); SynchronizedStreamObserver<PlatformInboundInstruction> inputStream = new SynchronizedStreamObserver<>( PlatformServiceGrpc.newStub(intercepted(context, channels.get(context))) .openStream(new UpstreamAwareStreamObserver<PlatformOutboundInstruction>() { @Override public void onNext(PlatformOutboundInstruction messagePlatformOutboundInstruction) { Collection<BiConsumer<PlatformOutboundInstruction, StreamObserver<PlatformInboundInstruction>>> defaultHandlers = Collections .singleton((poi, stream) -> sendUnsuccessfulInstructionResult( messagePlatformOutboundInstruction.getInstructionId(), unsupportedInstruction(), stream)); handlers.getOrDefault(context, messagePlatformOutboundInstruction.getRequestCase(), defaultHandlers) .forEach(consumer -> consumer.accept(messagePlatformOutboundInstruction, (StreamObserver<PlatformInboundInstruction>) getRequestStream())); } @Override public void onError(Throwable throwable) { logger.warn("Lost instruction stream from - {}", name, throwable.getMessage()); notifyConnectionChange(disconnectListeners, context); if (throwable instanceof StatusRuntimeException) { StatusRuntimeException sre = (StatusRuntimeException) throwable; if (sre.getStatus().getCode().equals(Status.Code.PERMISSION_DENIED)) { return; } } scheduleReconnect(context, true); } @Override public void onCompleted() { logger.info("Closed instruction stream to [{}]", name); notifyConnectionChange(disconnectListeners, context); scheduleReconnect(context, true); } }) ); inputStream.onNext(PlatformInboundInstruction.newBuilder().setRegister(clientIdentification).build()); StreamObserver<PlatformInboundInstruction> existingStream = instructionStreams.put(context, inputStream); if (existingStream != null) { existingStream.onCompleted(); } }

Target:
private synchronized void startInstructionStream(String context, String name, ClientIdentification clientIdentification) { logger.debug("Start instruction stream to node for context [{}]", name, context); SynchronizedStreamObserver<PlatformInboundInstruction> inputStream = new SynchronizedStreamObserver<>( getPlatformStream(context, new UpstreamAwareStreamObserver<PlatformOutboundInstruction>() { @Override public void onNext(PlatformOutboundInstruction messagePlatformOutboundInstruction) { Collection<BiConsumer<PlatformOutboundInstruction, StreamObserver<PlatformInboundInstruction>>> defaultHandlers = Collections .singleton((poi, stream) -> instructionAckSource .sendUnsupportedInstruction(poi.getInstructionId(), axonServerConfiguration.getClientId(), requestStreamFactory.apply(this))); handlers.getOrDefault(context, messagePlatformOutboundInstruction.getRequestCase(), defaultHandlers) .forEach(consumer -> consumer.accept(messagePlatformOutboundInstruction, requestStreamFactory.apply(this))); } @Override public void onError(Throwable throwable) { logger.warn("Lost instruction stream from - {}", name, throwable.getMessage()); notifyConnectionChange(disconnectListeners, context); if (throwable instanceof StatusRuntimeException) { StatusRuntimeException sre = (StatusRuntimeException) throwable; if (sre.getStatus().getCode().equals(Status.Code.PERMISSION_DENIED)) { return; } } scheduleReconnect(context, true); } @Override public void onCompleted() { logger.info("Closed instruction stream to [{}]", name); notifyConnectionChange(disconnectListeners, context); scheduleReconnect(context, true); } }) ); inputStream.onNext(PlatformInboundInstruction.newBuilder().setRegister(clientIdentification).build()); StreamObserver<PlatformInboundInstruction> existingStream = instructionStreams.put(context, inputStream); if (existingStream != null) { existingStream.onCompleted(); } }