5 Replies Latest reply on Apr 13, 2017 8:20 AM by WolfShade

    How to speed up of output json object format to feed into the cfhttp

    henryc62208508

      The following codes take more then 12 hours to run for only more than 300,000 records in the table. How do I speed up the process? Is there another way to generate the json object and feed into the cfhttp in a faster manner? Thanks.

      ----------------------------------------------------

            <cfquery name="getData" datasource="#request.dsn#">

                SELECT     District, Route, DateTime, Site, TicketNumber, Tons, CommodityCode, GeneralCommodity, DateCreated

                      FROM         tSolidResourcesTonnages

            </cfquery>

            <cfif getData.recordcount gt 0>

                <cfloop query="getData">

                          <cfset variables.objJson = variables.objJson & "{'district': '#HTMLEditFormat(getData.District)#'," &

                       "'route': '#HTMLEditFormat(getData.Route)#'," &

                       "'datetime': '#HTMLEditFormat(getData.Datetime)#'," &

                       "'site': '#HTMLEditFormat(getData.Site)#', " &

                       "'ticketnumber': '#HTMLEditFormat(getData.TicketNumber)#'," &

                       "'tons': #HTMLEditFormat(getData.Tons)#," &

                       "'commoditycode': '#HTMLEditFormat(getData.CommodityCode)#'," &

                       "'generalcommodity': '#HTMLEditFormat(getData.GeneralCommodity)#'" &                

                      "},">

              </cfloop>

              <cfset variables.objJson = #mid(variables.objJson,1,len(variables.objJson)-1)# & "]">       

              <!---Note: method: put is to replace, post is to append--->

              <cfhttp url="#request.SolidResourcesTonnages_ApiUrl#" method="put" result="uploadResponse" timeout="30000" proxyServer="#request.proxyServer#" proxyport="#request.proxyPort#">

                <cfhttpparam type="header" name="Authorization" value="Basic #ToBase64(request.myCredential)#" />

                <cfhttpparam type="header" name="X-App-Token" value="#request.appToken#">

                <cfhttpparam type="header" name="Content-Type" value="application/json; charset=utf-8">

                <cfhttpparam type="body" value="#variables.objJson#">

              </cfhttp>

            </cfif>

      --------------------------------------------------------------------------------