Search code examples
objectdynamics-crm-2011poolxrm

Connection/Object pool for OrganizationServiceProxy in XRM/Dynamics CRM 2011


I am writing a MVC 3 WebApp which uses XRM 2011 using Early Bound. This is an internet-facing application hosted on separate machine than Dynamics IIS.

This of course makes OrganizationServiceProxy call very very frequently and response is kind of sluggish on every first hit.

Is it advisable to reuse OrganizationServiceProxy connection rather than create new instance every time?

If yes,

  1. Is there anything to manage the connections such as
    • connection pool app - MS or third party/open source
    • or some framework like WCF (Never used WCF, yet)
  2. Which design pattern is recommended if I have to write my own code to manage connection?

Sorry for the duplicate post from MS website. Hopefully this forum is more active.


Solution

  • After few test cycles, I have found that using CrmConection is the fastest method. Compared to above caching implementation, CrmConnection runs at least 5 times faster.

    CrmConnection connection = new CrmConnection("XrmConnectionString");   // Todo: Replace magic connection string
    using (XrmVRC.XrmVrcServiceContext context = new XrmVRC.XrmVrcServiceContext(connection)) {
        // Processing...
    }