Skip to Main Content
Return to Navigation

Content-Based Routing

With PeopleSoft Integration Broker, you typically define the routing information separately from the message itself. This allows you to apply multiple routings to a message and change the routings independent of the message definition.

With content-based routing, attributes of the message are used to make routing decisions. The attributes are set before the message is published. Then, within your implementation of the IRouter.OnRouteSend method, these attributes can be examined and evaluated—for example, to send the message to a defined list of nodes instead of to all nodes. Because the attributes are separate from the message data, the Message object itself does not have to be parsed and loaded into a rowset and then searched to get the routing information. This separation of routing attributes from the message data provides a performance improvement over having those routing attributes within the message content.

In the following example, the routing attributes are set with calls to the AddAttribute method of the IBInfo class:

Local Message &MSG;
Local Rowset &FLIGHT_PROFILE;
Local string &AC_Type, &Pilot;
Local boolean &bRet;

&FLIGHT_PROFILE = GetLevel0();

&MSG = CreateMessage(Operation.QE_FLIGHTPLAN);

&AC_Type = GetLevel0().GetRow(1).GetRecord(Record.QE_FLIGHTDATA).AC_TYPE.Value;
&Pilot = GetLevel0().GetRow(1).GetRecord(Record.QE_FLIGHTDATA).PILOT.Value;

&bRet = &MSG.IBInfo.AddAttribute("ACType", &AC_Type);
&bRet = &MSG.IBInfo.AddAttribute("Pilot", &Pilot);

&MSG.CopyRowset(&FLIGHT_PROFILE);

%IntBroker.Publish(&MSG);

Then, in the implementation-specific IRouter.OnRouteSend method, the message attributes are evaluated to make routing decisions. The OnRouteSend method does not load and examine the Message object itself, only the attributes:

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;
   method GetDestinationList(&AC_Type As string, &Pilot As string) Returns any;
   
end-class;

/* constructor */
method RoutingHandler
end-method;

method OnRouteSend
   /+ &MSG as Message +/
   /+ Returns Integer +/
   /+ Extends/implements PS_PT:Integration:IRouter.OnRouteSend +/
   /* Variable Declaration */
   Local string &AC_Type;
   Local string &Pilot;
   Local any &aNodeList;
   Local integer &i;
   
   If &MSG.IBInfo.GetNumberOfAttributes() = 0 Then
      Return (%IntBroker_ROUTE_NONE);
   End-If;
   
   For &i = 1 To &MSG.IBInfo.GetNumberOfAttributes()
      
      If &MSG.IBInfo.GetAttributeName(&i) = "ACType" Then
         &AC_Type = &MSG.IBInfo.GetAttributeValue(&i);
      End-If;
      
      If &MSG.IBInfo.GetAttributeName(&i) = "Pilot" Then
         &Pilot = &MSG.IBInfo.GetAttributeValue(&i);
      End-If;
      
   End-For;
   /* method evaluates these strings and return NodeList */
   &aNodeList = %This.GetDestinationList(&AC_Type, &Pilot);
   
   Evaluate &aNodeList
   When "True"
      Return (%IntBroker_ROUTE_ALL);
      Break;
   When "False"
      Return (%IntBroker_ROUTE_NONE);
      Break;
   When-Other
      &destinationNodes = &aNodeList.Clone();
      Break;
   End-Evaluate;
   
end-method;

method GetDestinationList
   /+ &AC_Type as String, +/
   /+ &Pilot as String +/
   /+ Returns Any +/
   
   /* determine node list based on input data */
   
   Return Null;
end-method;