Real-Time Incremental Feeds
Creating real-time incremental feeds also requires additional steps. You must complete the following tasks when creating real-time incremental feeds:
-
Define the DSPARAMETER_INCREMENTAL data source parameter found in the PTFP_FEED:UTILITY:Utility application class and set it to an appropriate value in your implementation of the processSettingsChange method for your data source :
&thisDSP = %This.addParameter(&utility.DSPARAMETER_INCREMENTAL, ⇒ String(&utility.INCREMENTALOPTION_NO)); &thisDSP.Name = &thisDSP.ID; &thisDSP.Description = MsgGetText(219, 3008, "Message Not Found - Incremental"); &thisDSP.FieldType = &utility.FIELDTYPE_SIGNEDNUMBER; &thisDSP.DefaultValue = String(&utility.INCREMENTALOPTION_NO); &thisDSP.Value = &thisDSP.DefaultValue; &thisDSP.Required = True;Important:
The incremental feed option is incompatible with the paged feed option. Do not allow both options to be set simultaneously.
-
Modify the associated advanced feed options page to allow feed administrators the ability to set this option.
-
Generate delta feed entries in your implementation of the execute method for your data source based on the QUERYPARAMETER_IFMODIFIEDSINCE query parameter of the PTFP_FEED:UTILITY:Utility application class.
Your implementation of the execute method must contain both the QUERYPARAMETER_IFNONEMATCH and the QUERYPARAMETER_IFMODIFIEDSINCE query parameters. QUERYPARAMETER_IFNONEMATCH is the feed ID and QUERYPARAMETER_IFMODIFIEDSINCE is the time at which the feed was last requested.
The following code excerpt shows how to get the QUERYPARAMETER_IFNONEMATCH and QUERYPARAMETER_IFMODIFIEDSINCE query parameters using RequestInfo in the execute method of the data source:
Local PTFP_FEED:DataSource:DataSourceParameter &thisDSP; Local string &ifNoneMatch, &ifModifiedSince, &select; Local datetime &lastmodified_dt = DateTime6(1900, 1, 1, 0, 0, 0); Local boolean &incremental; /* Get the Incremental Parameter */ &thisDSP = %This.getParameterById(&utility.DSPARAMETER_INCREMENTAL); If &thisDSP <> Null And (&thisDSP.EvaluatedValue = String(&utility.INCREMENTALOPTION_YES)) Then &incremental = True; Else &incremental = False; End-If; &ifNoneMatch = &utility.RequestInfo.getParameter(&utility.QUERYPARAMETER_⇒ IFNONEMATCH); &ifModifiedSince = &utility.RequestInfo.getParameter(&utility.QUERYPARAMETER_⇒ IFMODIFIEDSINCE); If All(&ifModifiedSince) Then &lastmodified_dt = &utility.httpStringToDatetime(&ifModifiedSince); End-If; /* Compare and verify that &ifNoneMatch is same as the feed ID */ /* Compare the &lastmodified_dt with appropriate datetime column like the */ /* LASTUPDDTTM field in the record used for generating the feed entries */ -
When the execute method of a data source returns no feed entries, the Feed Publishing Framework issues a 304-Not Modified HTTP header. If you are using a custom feed handler—that is, a service operation different from the PTFP_GETFEED service operation —then use the setMessageHeadersAndMimeType method to set HTTP conditional headers.
For example:
method OnRequest /+ &pRequestMsg as Message +/ /+ Returns Message +/ /+ Extends/implements PS_PT:Integration:IRequestHandler.OnRequest +/ Local Message &responseMsg; Local XmlDoc &xmlDoc; Local string &temp, &errorText; Local PTFP_FEED:UTILITY:Utility &utility = &feedFactory_inst.Utility; Local PTFP_FEED:XML_FEED:FeedDoc &feedDoc; Local PTFP_FEED:UTILITY:FeedRequest &request; /* Ccreate the Search Request object */ &request = create PTFP_FEED:UTILITY:FeedRequest("FeedRequest"); ... try &feedDoc = &feedFactory_inst.getFeedDoc(&request); catch PTFP_FEED:EXCEPTION:NotFoundException &ex1 &errorText = MsgGetExplainText(219, 3112, "(Message not found) Not Found"); catch PTFP_FEED:EXCEPTION:PrivilegeException &ex2 &errorText = MsgGetExplainText(219, 3113, "(Message not found) ⇒ Not Authorized"); catch PTFP_FEED:EXCEPTION:FeedException &ex3 &errorText = &utility.getExceptionText(&ex3); end-try; /* Create the response message */ &responseMsg = CreateMessage(Operation.PTFP_GETFEED, %IntBroker_Response); If None(&errorText) Then &responseMsg = &utility.setMessageHeadersAndMimeType(&responseMsg, ⇒ &feedDoc, &request); Else &temp = "<?xml version='1.0' encoding='UTF-8'?><ErrorMessage>" | ⇒ &errorText | "</ErrorMessage>"; &xmlDoc = CreateXmlDoc(&temp); &responseMsg.SetXmlDoc(&xmlDoc); &responseMsg.SegmentContentType = &utility.MIMETYPE_XML; End-If; Return &responseMsg; end-method;