Propagating a message to the JavaCompute node Out and Alternate terminals
The JavaCompute node has two output terminals, Out and Alternate. Therefore, you can use the node both as a filter node and as a message transformation node. After you process the message, propagate the message to an output terminal by using a propagate() method.
About this task
out.propagate(assembly);
To propagate the message assembly to the Alternate terminal,
use the following method: alt.propagate(assembly);
MbMessage outMessage = new MbMessage(inMessage);
MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
...
newMsg.finalizeMessage(MbMessage.FINALIZE_NONE);
out.propagate(outAssembly);
...
newMsg.finalizeMessage(MbMessage.FINALIZE_NONE);
out.propagate(outAssembly);
MbOutputTerminal.propagate(MbMessageAssembly, true)
This
code recovers the message tree and parser resources after the propagation
so that these resources can be used when the next MbMessage is constructed
for propagation. You can see an example in Working with large input messages to propagate multiple output messages.When you use this code, the message tree resources are reclaimed for the non-read-only MbMessages in the MbMessageAssembly. As a result, the method MbMessage.clearMessage(true) is called on each modifiable MbMessage; therefore, these MbMessages cannot be used again.
If message tree fields were local to each MbMessage, or were only detached or attached between the three MbMessages in the MbMessageAssembly, the parsers are also recovered for reuse. However, if elements were detached and attached to an MbMessage that was not propagated, the parsers cannot be reused on the next iterations of input records.
For such MbMessage objects that were not propagated, call the method MbMessage.clearMessage(true) explicitly before the next input record is processed. This method allows parsers to be reused.