Routing Methods

Routing methods determine how a message is routed to or from PeopleSoft Integration Broker.

OnRouteSend Method

Implement the OnRouteSend method for outbound synchronous and asynchronous service operations to specify to what node PeopleSoft Integration Broker routes a message. The implementation of this method enables you to apply PeopleCode that filters the destination nodes to which PeopleSoft Integration Broker routes messages.

The OnRouteSend method is contained in the IRouter application class, which is contained in the PS_PT application package, in the Integration subpackage.

When the application PeopleCode is invoked to send a message, the routing definitions in the local database provide a list of target nodes to which PeopleSoft Integration Broker can route the message. The integration engine’s request handler invokes the service operation's OnRouteSend event. You can implement the OnRouteSend method in the application package associated with the handler for this service operation, which enables you to apply additional PeopleCode that determines the final target nodes.

You can use OnRouteSend to validate the outbound service operation's target node list, prevent the message from transmitting, or redirect it to a completely different set of targets.

The following table lists the PeopleCode built-in constants that you can use with the OnRouteSend method:

Constant Description

%IntBroker_ROUTE_NONE

Do not 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.

OnRouteSend enables you to account for multiple synchronous targets. Only one target node at a time can receive a request message sent with a synchronous transaction. Even though you can define the same outbound synchronous transaction for multiple nodes, you must make sure the transaction resolves to a single target node or the transaction fails.

The following code example shows an implementation of this class:

import PS_PT:Integration:IRouter;

class RoutingHandler implements PS_PT:Integration:IRouter
   method RoutingHandler();
   property array of any destinationNodes;
   method OnRouteSend(&_MSG As Message) Returns integer;
end-class;

/* constructor */
method RoutingHandler
end-method;

method OnRouteSend
   /+ &_MSG as Message +/
   /+ Returns Integer +/
   /+ Extends/implements PS_PT:Integration:IRouter.OnRouteSend +/
   /* Variable Declaration */
   Local any &aNodeList;
   Local any &rootNode;
   Local any &xmlDoc;
   /* Check the message for the instructions on how to execute
     the OnRouteSend.*/
   &xmlDoc = &_MSG.GetXmlDoc();
   &rootNode = &xmlDoc.DocumentElement;
   &aNodeList = &rootNode.GetElementsByTagName("OnRouteSend");
   If (&aNodeList.Len <> 1) Then
      /* No Nodes are in the list, therefore exit. */
      Exit;
   Else
      /* check the value of the node to determine the action to 
       take. */
      Evaluate &aNodeList [1].NodeValue
      When "True"
         Return (%IntBroker_ROUTE_ALL);
         Break;
      When "False"
         Return (%IntBroker_ROUTE_NONE);
         Break;
      When-Other
         /* assume that this is to be routed to the node given */
         Local array &nodeArray;
         &nodeArray = CreateArray();
         &nodeArray.Push(&aNodeList [1].NodeValue);
         Local string &sIBVariableTest = GetCurrentType(&nodeArray);
         Evaluate &sIBVariableTest
         When "Array"
            &destinationNodes = &nodeArray.Clone();
            Return %IntBroker_ROUTE_SOME;
         When "BooleanTrue"
            Return %IntBroker_ROUTE_ALL;
         When "BooleanFalse"
            Return %IntBroker_ROUTE_NONE;
         End-Evaluate;
         Break;
      End-Evaluate;
   End-If;
end-method;

OnRouteReceive Method

Implement the OnRouteReceive method for inbound synchronous and asynchronous service operations to apply PeopleCode that determines whether the default local node accepts inbound messages.

The OnRouteReceive method is contained in the IRouter application class, which is contained in the PS_PT application package, in the Integration subpackage.

When the integration engine receives a message, the transaction definitions in the local database provide a list of source nodes from which the application can accept the message. The integration engine’s request handler invokes the service operation's OnRouteReceive event. You can implement the OnRouteReceive method in the application package associated with the handler for this service operation, which enables you to apply PeopleCode that determines whether the default local node accepts the inbound message. You can employ this event regardless of the message transmission type.

The following is an example implementation of this method:

import PS_PT:Integration:IRouter;

class RoutingHandler implements PS_PT:Integration:IRouter
   method RoutingHandler();
   property array of any destinationNodes;
   method OnRouteReceive(&_MSG As Message) Returns boolean;
end-class;

/* constructor */
method RoutingHandler
end-method;

method OnRouteReceive
   /+ &_MSG as Message +/
   /+ Returns Boolean +/
   /+ Extends/implements PS_PT:Integration:IRouter.OnRouteReceive +/
   /* Variable Declaration */
   Local any &aNodeList;
   Local any &rootNode;
   Local any &xmlDoc;
   /* Check the message for instructions on how to execute
    the OnRouteReceive.*/
   &xmlDoc = &_MSG.GetXmlDoc();
   &rootNode = &xmlDoc.DocumentElement;
   &aNodeList = &rootNode.GetElementsByTagName("OnRouteReceive");
   If (&aNodeList.Len <> 1) Then
      /* A single node must be present. */
      Exit;
   Else
      /* check the value of the node to determine the action to 
        take. */
      Evaluate &aNodeList [1].NodeValue
      When "True"
         Return ( True);
         Break;
      When "False"
         Return ( False);
         Break;
      When-Other
         /* don't recognize the value. */
         Exit;
      End-Evaluate;
   End-If;
end-method;