The PROPAGATE statement propagates a message to the downstream nodes.
>>-PROPAGATE--+--------------------------------------+--+----------------+--+----------+->< '-TO--+-TERMINAL--TerminalExpression-+-' '-MessageSources-' '-Controls-' '-LABEL--LabelExpression-------' WHERE |--MessageSources =--+-------------------------+--+---------------------+--+-----------------------+--| '-ENVIRONMENT--Expression-' '-MESSAGE--Expression-' '-EXCEPTION--Expression-' |--Controls =--+-----------------------+--+---------------------+--| '-FINALIZE--+-DEFAULT-+-' '-DELETE--+-DEFAULT-+-' '-NONE----' '-NONE----'
You can use the PROPAGATE statement in Compute and Database nodes, but not in Filter nodes. The additions to this statement assist in error handling - see Coding ESQL to handle errors.
'nowhere' : no propagation
'failure' : Failure
'out' : Out
'out1' : Out1
'out2' : Out2
'out3' : Out3
'out4' : Out4
-2 : no propagation
-1 : Failure
0 : Out
1 : Out1
2 : Out2
3 : Out3
4 : Out4
If the result of TerminalExpression is neither a CHARACTER nor an INTEGER, the broker throws an exception.
If there is neither a TO TERMINAL nor a TO LABEL clause, the broker propagates a message to the Out terminal.
If the result of LabelExpression is NULL or not of type CHARACTER, or there is no matching Label node in the flow, the broker throws an exception.
If there is neither a TO TERMINAL nor a TO LABEL clause, the broker propagates a message to the out terminal.
The MessageSources clauses select the message trees to be propagated. This clause is only applicable to the Compute node (it has no effect in the Database node).
ENVIRONMENT :
InputLocalEnvironment
OutputLocalEnvironment
Message :
InputRoot
OutputRoot
ExceptionList :
InputExceptionList
OutputExceptionList
If there is no MessageSources clause, the node's Compute mode property is used to determine which messages are propagated.
This clause is only applicable to the Compute node (it has no effect in a Database node).
If FINALIZE is set to DEFAULT, or the FINALIZE clause is absent, the output message (but not the Environment, Local Environment or Exception List) is finalized before propagation.
If FINALIZE is set to NONE, no finalization takes place. This option is required if you want to preserve and allow updates of the entire output message tree by the nodes downstream in the message flow and is used with DELETE NONE as described in the next section.
The DELETE clause is only applicable to the Compute node (it has no effect in a Database node).
If DELETE is set to DEFAULT, or the DELETE clause is absent, the output local environment, message, and exception list are all cleared and their memory recovered immediately after propagation.
If DELETE is set to NONE, nothing is cleared. Use DELETE NONE if you want the downstream nodes to be able to see a single instance of output local environment message, and exception list trees. Each propagate starts with the content of these trees as created by the previous propagate rather than starting with empty trees. If you also want these nodes to update the output tree, DELETE NONE must be used with the FINALIZE NONE option described in the previous section.
Note that the output trees that are finalized are cleared, regardless of which ones are propagated.
Propagation is a synchronous process. That is, the next statement is not executed until all the processing of the message in downstream nodes has completed. Be aware that this processing might throw exceptions and, if these exceptions are not caught, they will prevent the statement following the PROPAGATE call being reached. This behavior might be what the logic of your flow requires but, if it is not, you can use a handler to catch the exception and perform the necessary actions. Note that exceptions thrown downstream of a propagate, if not caught, will also prevent the final automatic actions of a Compute or Database node (for example, issuing a COMMIT Transaction set to Commit) from taking place.
If you are using the PROPAGATE statement in your node it is important that you use a RETURN FALSE; to prevent automatic propagation of the message to the next node in the message flow.
DECLARE i INTEGER 1;
DECLARE count INTEGER;
SET count = CARDINALITY(InputRoot.XMLNS.Invoice.Purchases."Item"[])
WHILE i <= count DO
--use the default tooling-generated procedure for copying message headers
CALL CopyMessageHeaders();
SET OutputRoot.XMLNS.BookSold.Item = InputRoot.XMLNS.Invoice.Purchases.Item[i];
PROPAGATE;
SET i = i+1;
END WHILE;
RETURN FALSE;
The following messages are produced on the Out terminal by the PROPAGATE statement:
<BookSold>
<Item>
<Title Category="Computer" Form="Paperback" Edition="2">The XML Companion </Title>
<ISBN>0201674866</ISBN>
<Author>Neil Bradley</Author>
<Publisher>Addison-Wesley</Publisher>
<PublishDate>October 1999</PublishDate>
<UnitPrice>27.95</UnitPrice>
<Quantity>2</Quantity>
</Item>
</BookSold>
<BookSold>
<Item>
<Title Category="Computer" Form="Paperback" Edition="2">A Complete Guide to
DB2 Universal Database</Title>
<ISBN>1558604820</ISBN>
<Author>Don Chamberlin</Author>
<Publisher>Morgan Kaufmann Publishers</Publisher>
<PublishDate>April 1998</PublishDate>
<UnitPrice>42.95</UnitPrice>
<Quantity>1</Quantity>
</Item>
</BookSold>
<BookSold>
<Item>
<Title Category="Computer" Form="Hardcover" Edition="0">JAVA 2 Developers
Handbook</Title>
<ISBN>0782121799</ISBN>
<Author>Phillip Heller, Simon Roberts </Author>
<Publisher>Sybex, Inc.</Publisher>
<PublishDate>September 1998</PublishDate> <UnitPrice>59.99</UnitPrice>
<Quantity>1</Quantity>
</Item>
</BookSold>