@Test public void getPlatformServer() { StreamObserver<PlatformInfo> responseObserver = new StreamObserver<PlatformInfo>() { @Override public void onNext(PlatformInfo platformInfo) { System.out.println(platformInfo.getPrimary()); } @Override public void onError(Throwable throwable) { } @Override public void onCompleted() { } }; ClientIdentification client = ClientIdentification.newBuilder().setClientId("client").setComponentName( "component").build(); platformService.getPlatformServer(client, responseObserver); }
@Override public void getPlatformServer(ClientIdentification request, StreamObserver<PlatformInfo> responseObserver) { String context = contextProvider.getContext(); eventPublisher.publishEvent(new ClientTagsUpdate(request.getClientId(), context, request.getTagsMap())); try { AxonServerNode connectTo = topology.findNodeForClient(request.getClientId(), request.getComponentName(), context); responseObserver.onNext(PlatformInfo.newBuilder() .setSameConnection(connectTo.getName().equals(topology.getName())) .setPrimary(NodeInfo.newBuilder().setNodeName(connectTo.getName()) .setHostName(connectTo.getHostName()) .setGrpcPort(connectTo.getGrpcPort()) .setHttpPort(connectTo.getHttpPort()) ).build()); responseObserver.onCompleted(); } catch (MessagingPlatformException cause) { logger.info("Error finding target for client {}/{}: {}", request.getClientId(), context, cause.getMessage()); responseObserver.onError(GrpcExceptionBuilder.build(cause)); } catch (RuntimeException cause) { logger.warn("Error processing client request {}", request, cause); responseObserver.onError(GrpcExceptionBuilder.build(cause)); } }
PlatformService extends PlatformServiceGrpc.PlatformServiceImplBase implements AxonServerClientService { @Override public void getPlatformServer(ClientIdentification request, StreamObserver<PlatformInfo> responseObserver) { String context = contextProvider.getContext(); eventPublisher.publishEvent(new ClientTagsUpdate(request.getClientId(), context, request.getTagsMap())); try { AxonServerNode connectTo = topology.findNodeForClient(request.getClientId(), request.getComponentName(), context); responseObserver.onNext(PlatformInfo.newBuilder() .setSameConnection(connectTo.getName().equals(topology.getName())) .setPrimary(NodeInfo.newBuilder().setNodeName(connectTo.getName()) .setHostName(connectTo.getHostName()) .setGrpcPort(connectTo.getGrpcPort()) .setHttpPort(connectTo.getHttpPort()) ).build()); responseObserver.onCompleted(); } catch (MessagingPlatformException cause) { logger.info("Error finding target for client {}/{}: {}", request.getClientId(), context, cause.getMessage()); responseObserver.onError(GrpcExceptionBuilder.build(cause)); } catch (RuntimeException cause) { logger.warn("Error processing client request {}", request, cause); responseObserver.onError(GrpcExceptionBuilder.build(cause)); } } }
PlatformService extends PlatformServiceGrpc.PlatformServiceImplBase implements AxonServerClientService { @Override public void getPlatformServer(ClientIdentification request, StreamObserver<PlatformInfo> responseObserver) { String context = contextProvider.getContext(); eventPublisher.publishEvent(new ClientTagsUpdate(request.getClientId(), context, request.getTagsMap())); try { AxonServerNode connectTo = topology.findNodeForClient(request.getClientId(), request.getComponentName(), context); responseObserver.onNext(PlatformInfo.newBuilder() .setSameConnection(connectTo.getName().equals(topology.getName())) .setPrimary(NodeInfo.newBuilder().setNodeName(connectTo.getName()) .setHostName(connectTo.getHostName()) .setGrpcPort(connectTo.getGrpcPort()) .setHttpPort(connectTo.getHttpPort()) ).build()); responseObserver.onCompleted(); } catch (MessagingPlatformException cause) { logger.info("Error finding target for client {}/{}: {}", request.getClientId(), context, cause.getMessage()); responseObserver.onError(GrpcExceptionBuilder.build(cause)); } catch (RuntimeException cause) { logger.warn("Error processing client request {}", request, cause); responseObserver.onError(GrpcExceptionBuilder.build(cause)); } } PlatformService(Topology topology,
                           ContextProvider contextProvider,
                           ClientIdRegistry clientIdRegistry,
                           ApplicationEventPublisher eventPublisher,
                           @Qualifier("platformInstructionAckSource")
                                   InstructionAckSource<PlatformOutboundInstruction> instructionAckSource); }
PlatformService extends PlatformServiceGrpc.PlatformServiceImplBase implements AxonServerClientService { @Override public void getPlatformServer(ClientIdentification request, StreamObserver<PlatformInfo> responseObserver) { String context = contextProvider.getContext(); eventPublisher.publishEvent(new ClientTagsUpdate(request.getClientId(), context, request.getTagsMap())); try { AxonServerNode connectTo = topology.findNodeForClient(request.getClientId(), request.getComponentName(), context); responseObserver.onNext(PlatformInfo.newBuilder() .setSameConnection(connectTo.getName().equals(topology.getName())) .setPrimary(NodeInfo.newBuilder().setNodeName(connectTo.getName()) .setHostName(connectTo.getHostName()) .setGrpcPort(connectTo.getGrpcPort()) .setHttpPort(connectTo.getHttpPort()) ).build()); responseObserver.onCompleted(); } catch (MessagingPlatformException cause) { logger.info("Error finding target for client {}/{}: {}", request.getClientId(), context, cause.getMessage()); responseObserver.onError(GrpcExceptionBuilder.build(cause)); } catch (RuntimeException cause) { logger.warn("Error processing client request {}", request, cause); responseObserver.onError(GrpcExceptionBuilder.build(cause)); } } PlatformService(Topology topology,
                           ContextProvider contextProvider,
                           ClientIdRegistry clientIdRegistry,
                           ApplicationEventPublisher eventPublisher,
                           @Qualifier("platformInstructionAckSource")
                                   InstructionAckSource<PlatformOutboundInstruction> instructionAckSource); @Override void getPlatformServer(ClientIdentification request, StreamObserver<PlatformInfo> responseObserver); @Override StreamObserver<PlatformInboundInstruction> openStream(
            StreamObserver<PlatformOutboundInstruction> responseObserver); boolean requestReconnect(ClientComponent clientName); boolean requestReconnect(String clientId); void sendToAllClients(PlatformOutboundInstruction instruction); void sendToClientStreamId(String clientStreamId, PlatformOutboundInstruction instruction); void sendToClient(String context, String clientId, PlatformOutboundInstruction instruction); @EventListener void on(PauseEventProcessorRequest evt); @EventListener void on(StartEventProcessorRequest evt); @EventListener void on(ApplicationDisconnected event); void onInboundInstruction(RequestCase requestCase, InstructionConsumer consumer); @EventListener void on(ProcessorStatusRequest event); @EventListener void on(ApplicationInactivityTimeout evt); Set<ClientComponent> getConnectedClients(); void requestReconnectForContext(String context); }
PlatformService extends PlatformServiceGrpc.PlatformServiceImplBase implements AxonServerClientService { @Override public void getPlatformServer(ClientIdentification request, StreamObserver<PlatformInfo> responseObserver) { String context = contextProvider.getContext(); eventPublisher.publishEvent(new ClientTagsUpdate(request.getClientId(), context, request.getTagsMap())); try { AxonServerNode connectTo = topology.findNodeForClient(request.getClientId(), request.getComponentName(), context); responseObserver.onNext(PlatformInfo.newBuilder() .setSameConnection(connectTo.getName().equals(topology.getName())) .setPrimary(NodeInfo.newBuilder().setNodeName(connectTo.getName()) .setHostName(connectTo.getHostName()) .setGrpcPort(connectTo.getGrpcPort()) .setHttpPort(connectTo.getHttpPort()) ).build()); responseObserver.onCompleted(); } catch (MessagingPlatformException cause) { logger.info("Error finding target for client {}/{}: {}", request.getClientId(), context, cause.getMessage()); responseObserver.onError(GrpcExceptionBuilder.build(cause)); } catch (RuntimeException cause) { logger.warn("Error processing client request {}", request, cause); responseObserver.onError(GrpcExceptionBuilder.build(cause)); } } PlatformService(Topology topology,
                           ContextProvider contextProvider,
                           ClientIdRegistry clientIdRegistry,
                           ApplicationEventPublisher eventPublisher,
                           @Qualifier("platformInstructionAckSource")
                                   InstructionAckSource<PlatformOutboundInstruction> instructionAckSource); @Override void getPlatformServer(ClientIdentification request, StreamObserver<PlatformInfo> responseObserver); @Override StreamObserver<PlatformInboundInstruction> openStream(
            StreamObserver<PlatformOutboundInstruction> responseObserver); boolean requestReconnect(ClientComponent clientName); boolean requestReconnect(String clientId); void sendToAllClients(PlatformOutboundInstruction instruction); void sendToClientStreamId(String clientStreamId, PlatformOutboundInstruction instruction); void sendToClient(String context, String clientId, PlatformOutboundInstruction instruction); @EventListener void on(PauseEventProcessorRequest evt); @EventListener void on(StartEventProcessorRequest evt); @EventListener void on(ApplicationDisconnected event); void onInboundInstruction(RequestCase requestCase, InstructionConsumer consumer); @EventListener void on(ProcessorStatusRequest event); @EventListener void on(ApplicationInactivityTimeout evt); Set<ClientComponent> getConnectedClients(); void requestReconnectForContext(String context);  }