public void onEvent(EventExchangeHolder eventExchangeHolder, long sequence, boolean endOfBatch) {
        boolean isProcessed = eventExchangeHolder.getAndSetIsProcessed(true);
        if (!isProcessed) {
            eventBuffer.add(eventExchangeHolder.getEvent());
            if (eventBuffer.size() == batchSize || endOfBatch) {
                for (StreamJunction.Receiver receiver : receivers) {
                    try {
                        receiver.receive(eventBuffer);
                    } catch (Exception e) {
                        onError(eventBuffer, e);
                    }
                }
                eventBuffer.clear();
            }
        } else if (endOfBatch) {
            if (eventBuffer.size() != 0) {
                for (StreamJunction.Receiver receiver : receivers) {
                    try {
                        receiver.receive(eventBuffer);
                    } catch (Exception e) {
                        onError(eventBuffer, e);
                    }
                }
                eventBuffer.clear();
            }
        }

    }
Interface to be implemented to receive events via handlers.
modules/siddhi-core/src/main/java/io/siddhi/core/util/event/handler/StreamHandler.java