protected void processAndClear(int processIndex, StreamEvent streamEvent) {
        ComplexEventChunk<StateEvent> retEventChunk = new ComplexEventChunk<StateEvent>();
        ComplexEventChunk<StreamEvent> currentStreamEventChunk = new ComplexEventChunk<StreamEvent>(streamEvent,
                streamEvent);

        ComplexEventChunk<StateEvent> eventChunk = ((StreamPreStateProcessor) nextProcessors[processIndex])
                .processAndReturn(currentStreamEventChunk);
        if (eventChunk.getFirst() != null) {
            retEventChunk.add(eventChunk.getFirst());
        }
        eventChunk.clear();

        if (querySelector != null) {
            while (retEventChunk.hasNext()) {
                StateEvent stateEvent = retEventChunk.next();
                retEventChunk.remove();
                querySelector.process(new ComplexEventChunk<StateEvent>(stateEvent, stateEvent
                ));
            }
        }

    }
Implementation of {StreamJunction.Receiver} to receive events to be fed into
multi stream stateful queries.
modules/siddhi-core/src/main/java/io/siddhi/core/query/input/StateMultiProcessStreamReceiver.java