Interface MultiOutputIterator<T>
- Type Parameters:
T- the record type
- Split mode (
setIterator(Iterator)): a single tagged iterator routes each record to a specific output connection viaTaggedOutput. Use when records come from one shared source and must be split between outputs. - Independent mode (
setIterator(String, Iterator)): each output connection gets its own independent lazy iterator, consumed in parallel by the drain loop. Use when each output has its own self-contained lazy source.
Both modes can be selected at runtime from the same fixed method parameter, so the component does not need separate parameters per output.
It is equally valid to use it with a single output: the point is then to stream records lazily
instead of pushing them through an OutputEmitter, which avoids buffering. In that case the
branch is named as usual with @Output("FLOW"); @Output(branches = ...) is only needed
when the parameter feeds several branches, to declare them to the design layer.
Important: This interface is supported only in the Studio DI runtime.
Split mode example (one source, per-record routing):
@ElementListener
public void process(@Input Record input,
@Output(branches = { "MAIN", "REJECT" }) MultiOutputIterator<Record> out) {
out.setIterator(
mySource.stream()
.map(r -> isValid(r)
? TaggedOutput.of("MAIN", transform(r))
: TaggedOutput.of("REJECT", r))
.iterator());
}
Independent mode example (each output has its own lazy source):
@AfterGroup
public void afterGroup(@Output(branches = { "MAIN", "REJECT" }) MultiOutputIterator<Record> out) {
out.setIterator("MAIN", mainDatabase.lazyQuery());
out.setIterator("REJECT", errorLog.lazyRead());
}
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidsetIterator(String outputName, Iterator<T> iterator) Independent mode: assigns a lazy iterator to a specific named output connection.voidsetIterator(Iterator<TaggedOutput<T>> iterator) Split mode: sets a single lazy iterator whose elements are tagged with the target output connection name viaTaggedOutput.
-
Method Details
-
setIterator
Split mode: sets a single lazy iterator whose elements are tagged with the target output connection name viaTaggedOutput. The runtime reads one record at a time and routes it to the matching connection.Mutually exclusive with
setIterator(String, Iterator)within one invocation.- Parameters:
iterator- the tagged iterator routing records to their named outputs
-
setIterator
Independent mode: assigns a lazy iterator to a specific named output connection. Call once per output that needs a dedicated lazy source; connections without an assigned iterator fall back to the push-mode queue as usual.Mutually exclusive with
setIterator(Iterator)within one invocation.- Parameters:
outputName- the output connection name (e.g."MAIN","REJECT")iterator- the lazy iterator producing records for that connection
-