See information about the latest product version
@MessageBrokerRouter
Use the @MessageBrokerRouter annotation to alter the behavior of the evaluate method in a PHP class.
The @MessageBrokerRouter annotation causes the return value of the evaluate method to be used to specify the terminal through which the message is to be propagated. The terminal can be either the Out terminal (defined on the node) or a dynamic terminal that you have created. You can add output terminals dynamically to your node instance in the Message Flow editor. The string that is returned from the evaluate method must match either the name of the dynamic terminal that you have defined or the Out terminal. If no return value is specified, the output assembly is not propagated to the next node after the evaluate method returns.
The following example routes the message to the Out terminal if the value of the threshold element is greater than 10; otherwise the message is routed to the other terminal:
<?php
class RouteTest {
/**
* Basic routing of a message.
*
* @MessageBrokerRouter
*/
function evaluate($assembly) {
// Simple filter
if ($assembly->XMLNSC->doc->threshold->getValue() > 10) {
return 'out';
} else {
return 'other';
}
}
}
?>
For information about dynamic terminals, see Using dynamic terminals.