OutputPort
An OutputPort represents a connection from one processor to another within a workflow. You obtain output ports through processor.getOutputPort(), then use them with stream.emit() to send messages downstream.
At a Glance
// Get an output port by name (typically done in onInit)
const OUTPUT_PORT = processor.getOutputPort('Output');
// Emit a message to it
stream.emit(message, OUTPUT_PORT);
Properties
| Property | Type | Description |
|---|---|---|
name | string | The name of this output port |
peerPortName | string | The name of the connected input port on the downstream processor |
peerProcessorName | string | The name of the downstream processor |
name
The output port name as defined in the workflow diagram.
const portName = outputPort.name; // e.g., "Output", "Error", "Valid"
peerPortName
The name of the input port on the connected downstream processor.
const connectedTo = outputPort.peerPortName; // e.g., "Input"
peerProcessorName
The name of the processor this port connects to.
const nextProcessor = outputPort.peerProcessorName; // e.g., "Transform-Data"
Methods
getName()
Returns the output port name. Same as name.
Returns: string
const name = outputPort.getName();
getPeerPort()
Returns the name of the connected peer input port. Same as peerPortName.
Returns: string
const peer = outputPort.getPeerPort();
getPeerProcessorName()
Returns the name of the downstream processor. Same as peerProcessorName.
Returns: string
const processorName = outputPort.getPeerProcessorName();
getProcessorName()
Returns the name of the processor that owns this output port (the current processor).
Returns: string
const myName = outputPort.getProcessorName();
Complete Example
// Initialize ports in onInit
let OUTPUT_PORT;
let ERROR_PORT;
export function onInit() {
OUTPUT_PORT = processor.getOutputPort('Output');
ERROR_PORT = processor.getOutputPort('Error');
}
export function onMessage() {
// Route based on validation
if (message.hasStatusAttached(Severity.ERROR)) {
stream.emit(message, ERROR_PORT);
} else {
stream.emit(message, OUTPUT_PORT);
}
}
See Also
Processor#getOutputPort— Obtain output ports by nameStream#emit— Send messages through output ports