ReturnToServer function
Syntax
ReturnToServer({True | False | &NODE_ARRAY, | &Message})
Description
Use the ReturnToServer function to return a value from a PeopleCode messaging program to the publication or subscription server.
Note:
ReturnToServer is a special case of a built-in function that's no longer supported. The desupported handler for OnRequest subscriptions cannot be upgraded. ReturnToServer can only be used in an OnRequest event fired using the desupported handler. This means that ReturnToServer no longer works and is not valid in any case other than when the code has already been written and used in a desupported handler.
You would use this in either your publication or subscription routing code, to either return an array of nodes that the message should be published to, or to do error processing (return False if entire message wasn’t received.)
What is returned depends on where the PeopleCode program is called from.
From OnRoute Publication:
-
True: All nodes the message was published to are returned.
-
False: No nodes are returned (generally used with error checking).
-
&NODE_ARRAY: The nodes specified in the array are returned.
-
&Message: Return a response message. This must be an already instantiated message object.
Note:
You can return XmlDoc objects as responses. Only homogeneous type transactions are supported, that is, you can only return an XmlDoc object as a response if and only if an XmlDoc object was used in the request. Similarly, you can only return a Message object if and only if a Message object was used in the request.
From OnRoute Subscription:
-
True: The subscription node is returned.
-
False: No node is returned. This is generally used with error checking.
Parameters
| Parameter | Description |
|---|---|
|
True | False |&NODE_ARRAY | &Message |
Specify True if you want publication nodes or the subscription node returned. Specify False if you do not want any nodes returned, and nothing written to the database. This is generally used with error checking. Specify an object reference to an array of node names if you want to return a list of nodes to be published to. Specify a reference to a response message if you want to return a message. |
Returns
None.
Example
The following is an example of a publication routing rule, which would be in the OnRoutePublication. It is used to create publication contracts.
local message &MSG;
local array &NODE_ARRAY;
&MSG = GetMessage();
&EMPLID = &MSG.GetRowset()(1).QA_INVEST_HDR.EMPLID.Value;
&SELECT_SQL = CreateSQL("select PUBNODE from PS_EMPLID_NODE where EMPLID = :1",⇒
&EMPLID);
&NODE_ARRAY = CreateArray();
While &SELECT_SQL.Fetch(&PUBNODE)
&NODE_ARRAY.Push(&PUBNODE);
End-While;
ReturnToServer(&NODE_ARRAY);
The following is an example of a subscription routing rule, which would be placed in the OnRouteSubscribe event:
local message &MSG;
&MSG = GetMessage();
&BUSINESS_UNIT = &MSG.GetRowset()(1).PO_HDR.BUSINESS_UNIT.Value;
SQLExec("Select BUSINESS_UNIT From PS_BUSINESS_UNIT where BUSINESS_UNIT = :⇒
1",&BUSINESS_UNIT,&FOUND);
If all(&FOUND) Then
ReturnToServer(True);
Else
ReturnToServer(False);
End-if;
The following is a basic example of using an XmlDoc object:
Local XmlDoc &xmldoc;
. . .
/* build xmldoc */
. . .
ReturnToServer(&xmldoc);