OnRouteSend

OnRouteSend: This event triggers before the publication contracts are created and allows you to remove or modify the contracts that are created programmatically. You can inspect the message content and override Service Operation routings. We use this OnRouteSend to override node publication and selectivity not publish to certain nodes at certain times. This is used for asynchronous service operations.

/* This interface is the equivalent of the OnRouteSend  and OnRouteReceive 
PeopleCode events in 8.4x tools. OnRouteSend will pass in a message to 
your derived application class method. The return should be an integer. 
%IntBroker_ROUTE_NONE = Do send this operation to any of the possible nodes
%IntBroker_ROUTE_SOME = Send this operation to a selected list of nodes. 
The node list should be an array of strings in the property "destinationNodes".
%IntBroker_ROUTE_ALL = Send this operation to all nodes that have a valid routing.

OnRouteReceive will pass in a message to your derived application 
class method. The return should be a Boolean. 
FALSE = The Operation will not run locally
TRUE = The Operation will run locally.

If an error occurs the OnError method if implemented will be 
automatically invoked. The type of exception can be viewed by using the 
Message object to retrieve the Exception object (&Message.IBException).
Please see the PeopleCode Language Reference guide for 
more information about the Exception class.
*/

interface IRouter
   method OnRouteSend(&message As Message) Returns integer;
   method OnRouteReceive(&message As Message) Returns boolean;
   method OnError(&request As Message);
   property array of any destinationNodes;
end-interface;

```


In my testing even if you return `%IntBroker_ROUTE_NONE`, local subscriptions will trigger still. You can’t use this to stop local subscriptions from processing in an local operation instance. You have to do something like this in the subscription handler.

```
If &_MSG.IsLocal And
         &_MSG.IBInfo.OrigNode <> &_MSG.IBInfo.SourceNode Then
              do not run code because this is a secondary operation instance that got triggered 
```



> OnRouteSend will pass in a message to your derived application class method. The return should be an integer. 
> %IntBroker_ROUTE_NONE = Do send this operation to any of the possible nodes
> %IntBroker_ROUTE_SOME = Send this operation to a selected list of nodes. 
> The node list should be an array of strings in the property "destinationNodes".
> %IntBroker_ROUTE_ALL = Send this operation to all nodes that have a valid routing.

Author Info
Chris Malek

Chris Malek is a PeopleTools® Technical Consultant with two decades of experience working on PeopleSoft enterprise software projects. He is available for consulting engagements.

About Chris Work with Chris