How can I improve the response times when accessing Salesforce?




  • Avatar
    Mike LeVasseur

    I'm using this sample code above to retrieve the Sales Force Session from SitecoreSalesforceSessionSingleton class.  This works great if you're constantly submitting leads to Sales Force.  However, if the website just came up for the first time (clean slate), the first end user will not benefit from a cached SalesForceSession and the submission will take around 10 - 12 seconds.  Is there a technique to pre-cache the SalesForceSession object when the website first comes up?   I tried doing this in the Global.ASCX in Application.Start()  but I get an error message from the S4S connector saying:


    [HttpException (0x80004005): Request is not available in this context]
       System.Web.HttpContext.get_Request() +12729234
       FuseIT.Sitecore.Salesforce.Licensing.isCurrentLicense(String orgId, String orgType) +436
       FuseIT.Sitecore.Salesforce.Licensing.License(String orgId, String orgType, Boolean internalComponent, Boolean isSandbox) +152
       FuseIT.Sitecore.SalesforceConnector.SalesforceSession.SetComponetPermissions(Boolean internalComponent) +149
       FuseIT.Sitecore.SalesforceConnector.SalesforceSession.Login(String userName, String password, Boolean internalComponent) +1101
       FuseIT.Sitecore.SalesforceConnector.SalesforceSession.Initialize(LoginDetails loginDetails, Boolean internalComponent, ProxySetting proxy) +1328
       FuseIT.Sitecore.SalesforceConnector.SalesforceSession..ctor(String connectionStringName, Boolean internalComponent, Boolean autoReestablishSession) +859
       FuseIT.Sitecore.SalesforceConnector.SalesforceSession..ctor(String connectionStringName, Boolean autoReestablishSession) +64
    Comment actions Permalink
  • Avatar

    Mike, thanks for going ahead and creating a proof of concept for us.

    To always keep the Salesforce session alive the preferred solution is to create a custom Sitecore page that only exists to maintain Salesforce session as per the FAQ Answer. The new custom.aspx page is periodically refreshed with a Sitecore UrlAgent scheduled event configured in web.config.

    The problem is that the custom.aspx page only gets called after the first period of time has elapsed. If the website restarts there is an initial delay before the Salesforce session is established.

    The solution is to create a custom processor in the initialize section of web.config (see SalesforceSessionInitializer processor below). The custom processor class spawns a new worker thread that makes a web request to the custom.aspx page. A new thread is required otherwise Sitecore will stop and wait indefinitely for a response.

    <!-- PIPELINES -->

    <processor type="Sitecore.Pipelines.Loader.ShowVersion, Sitecore.Kernel">
    <assemblies hint="list:AddAssembly">
    <processor type="Sitecore.Pipelines.Loader.ShowHistory, Sitecore.Kernel"/>

    <processor type="FuseIT.Web.UI.Pipeline.SalesforceSessionInitializer, FuseIT.Web.UI"/>


    Comment actions Permalink

Please sign in to leave a comment.