See information about the latest product version
Routing a message using a PHPCompute node
Route a message by using the PHPCompute node as a filter node.
Before you start:
Add a PHPCompute node to your message flow.
By default, the output message assembly is propagated to the Out terminal after the evaluate method in the PHP script has been processed. However, the PHPCompute node also has dynamic output terminals, so that you can use it as a filter node by propagating a message to the appropriate terminal, based on the message content.
You can use the @MessageBrokerRouter annotation in your PHP code to route the message to a terminal specified by the string return value of the evaluate method. If no string is returned, the message is not propagated.
The following example shows the @MessageBrokerRouter annotation in a PHP script file:
/**
* @MessageBrokerRouter
*/
function evaluate($message) {
if ($message->XMLNSC->doc->threshold->getValue() > 10) {
return 'out';
} else {
return 'other';
}
}
For more information about using the @MessageBrokerRouter annotation for message routing, see @MessageBrokerRouter.
Alternatively, you can propagate a message directly to a Label node. When you use this method, you do not need to use a RouteToLabel node, and you do not need to propagate messages to output terminals.

The following example shows the PHP code associated with the PHPCompute node in the message flow shown above. The PHP code specifies that the message is to be routed to the node called Label2:
…
$output->routeToLabel('Label2');