In this section: |
This section lists and describes different splitter exits used in iWay Service Manager (iSM).
Splitters are preparsers that break up large input messages into smaller messages that are processed piece by piece. Each piece flows through the work flow independently, as if it were a complete document. At the end of the stream, a special End of Stream (EOS) message is sent, enabling the subsequent exits in the flow to take any end-of-stream actions such as emitting aggregation documents, issuing commits, and so on.
Generally, exits downstream from a splitting preparser need not be concerned with the splitting of the message or with the end of stream signal. The exit processes the split portion exactly as it would a complete message. The exit can expose the boolean wantEOS() method to signal to the engine that the exit is to be called on EOS. False is the default value, so that if this method is not implemented by the exit, the exit is not invoked on EOS. To receive EOS signals, implement:
boolean wantEOS() { return true; }
Note: The Development Wizards set this as required.
In an execution method, such as a process of execute method in a business agent, the method can call:
int getStreamState()
to determine the state of the stream. Possible return values are:
Return Value | Description |
---|---|
STREAM_NONE | Exit is not operating in a streaming/splitting mode. This is the normal mode of a workflow. |
STREAM_ACTIVE | Exit was invoked for a split portion of a streamed document. |
STREAM_EOS | Exit was invoked to handle the EOS signal. No other data is available. In addition, special register EOS is defined with the value 1. |
Splitting is performed by preparsers. A splitting preparser must be the first user-configured preparser. Pre-built splitting preparsers are provided for XML, non-XML, and EDI messages.
This example shows two methods from a stream handling agent and illustrates the handling of EOS and non-EOS tasks. The agent emits an accumulated document when all parts have arrived, but avoids any output at non-EOS. The execute method adds each arriving part as a child of a root, and at EOS emits the new tree based on root.
List reps; // place to save replyTo list List errs; // place to save errorTo list XDNode accumroot=null; // build accumulation document here public String execute(XDDocument docIn, XDDocument docOut) throws XDException { int streamState = getStreamState(); // ask what state we are in XDNode passRoot; if (streamState != XDAgent.STREAM_EOS) { if (accumroot == null) // is this new document (new stream)? { accumroot=new XDNode("root"); // make root for accum document reps = docIn.getReplyTo(); // save the replyTo list errs = docIn.getErrorTo(); // save the errorTo list } passRoot = XDNode.cloneTree(docIn.getRoot()); // add to accum docOut.setRoot(null); // we want NO doc out docOut.setReplyTo(null); // clean out any replyto's docOut.addReplyTo(XD.PROTOCOL_NULL, null); // avoid ANY emit accumroot.setLastChild(passRoot); // add to accumulation } else // this is EOS, so emit accumulated document { docOut.setRoot(accumroot); // set last copy to output docOut.setReplyTo(reps); // restore replyTo docOut.setErrorTo(errs); // restore errorTo accumroot=null; // for next pass } return "success"; } protected boolean wantEOS() // added by development wizard { return true; // tell engine we want to receive the EOS signal }
iWay Software |