class EventProcessorService {

    @EventListener
    public void on(EventProcessorEvents.SplitSegmentRequest event) {
        EventProcessorSegmentReference splitSegmentRequest =
                EventProcessorSegmentReference.newBuilder()
                                              .setProcessorName(event.getProcessorName())
                                              .setSegmentIdentifier(event.getSegmentId())
                                              .build();

        PlatformOutboundInstruction instruction =
                PlatformOutboundInstruction.newBuilder()
                                           .setSplitEventProcessorSegment(splitSegmentRequest)
                                           .setInstructionId(UUID.randomUUID().toString())
                                           .build();
        SplitSegmentsSucceeded success = new SplitSegmentsSucceeded(event.context(),
                                                                    event.getClientId(),
                                                                    event.getProcessorName());
        instructionResultSource
                .onInstructionResultFor(instruction.getInstructionId())
                .subscribe(() -> eventPublisher.publishEvent(success),
                           error -> LOGGER.warn("Error during segment split: {}, {}", error, instruction),
                           timeout -> LOGGER.warn("The following operation is taking to long: {}", instruction));

        instructionPublisher.publish(event.context(), event.getClientId(), instruction);
    }

    @Autowired public  EventProcessorService(PlatformService instructionPublisher,
                                 InstructionResultSource.Factory instructionResultSource,
                                 AxonServerEventPublisher eventPublisher);
    public  EventProcessorService(
            InstructionPublisher instructionPublisher,
            InstructionResultSource.Factory instructionResultSource,
            AxonServerEventPublisher eventPublisher);

}