Write your own Consumer
This example shows a minimal consumer. It represents a sink which collects all incoming elements by saving them in a List.
public final class CollectorSink<T> extends AbstractConsumerStage<T> { private final List<T> elements = new ArrayList<T>(); @Override protected void execute(T element) { this.elements.add(element); // Collect and save } public List<T> getElements() { return elements; } }
By extending the class AbstractConsumerStage, the framework will automatically observe the input port and invoke the execute(T element) method on every incoming element. As a result, we solely need to implement the logics.
Here, we show how to pass on elements.