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

To propagate the message assembly to the Out terminal use the following method:
out.propagate(assembly);
To propagate the message assembly to the Alternate terminal, use the following method:
alt.propagate(assembly);
To propagate the same MbMessage object multiple times, call the finalizeMessage() method on the MBMessage object, so that any changes made to the message are reflected in the bit stream that is generated downstream of the JavaCompute node; for example:
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);
When you propagate many times from a JavaCompute node, where a new MbMessage is created each time, use the following code:
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.