locked
How to use Multi-threading to Create 1000's Records using - /XRMServices/2011/Organization.svc RRS feed

  • Question

  • Hi Guys

    Does anyone know how to use multi-threading to create 1000's of records using LINQ and /XRMServices/2011/Organization.svc

    I understand Multi-threading techniques but don't know how to apply them to this situation i.e. do I need to create multiple Service Context's etc....

    Thanks

    Thursday, April 21, 2011 2:48 PM

Answers

  • There is some (minimal) information in the SDK regarding Performance Best Practises for integrating with CRM Services:

    http://msdn.microsoft.com/en-us/library/gg509027.aspx#Performance

    Nothing specifc regarding multi-threading other than to use it.  Although the section on caching is probably pertinent to you.


    Caching

    To improve performance on requests to the Web services, you can statically cache the IServiceConfiguration class. In addition, monitor your WCF security token and refresh it before it expires. By refreshing the token before it expires, you will not lose the token and have to start over with authentication. To check the token, you can create a class that inherits from the OrganizationServiceProxyclass or the DiscoveryServiceProxy class, or wrap those classes in a new class. You can see an example of the first method in the ToolServiceProxies.cs and AutoRefreshSecurityToken.cs sample code files in the Tools\PluginRegistration folder of the SDK download. Another alternative method is to manually check the token before each call to the Web service.

    You should note that if you enable early bound types, you enable this for all proxies that use that IServiceConfiguration instance.

    If your application makes use of the metadata, it is recommended that you cache the metadata you have retrieved and to periodically call the RetrieveTimestampRequest message to determine if you need to refresh the cache.

     

     


    --pogo (pat)
    Thursday, April 21, 2011 8:07 PM
  • You need to make asynchronous web service calls to that service instead of synchronous. 

    http://msdn.microsoft.com/en-us/library/aa480512.aspx

     


    Jamie Miley
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Thursday, April 21, 2011 3:19 PM
    Moderator

All replies

  • You need to make asynchronous web service calls to that service instead of synchronous. 

    http://msdn.microsoft.com/en-us/library/aa480512.aspx

     


    Jamie Miley
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Thursday, April 21, 2011 3:19 PM
    Moderator
  • Hi Jamie

    I am using the Service Proxy to create records in CRM such as shown in http://msdn.microsoft.com/en-us/library/gg509009.aspx

    I would assume that the backend of these calls are using Web calls anyhow, so can't we do what you suggested but using the Service Proxy method?

     

    Thursday, April 21, 2011 4:39 PM
  • There is some (minimal) information in the SDK regarding Performance Best Practises for integrating with CRM Services:

    http://msdn.microsoft.com/en-us/library/gg509027.aspx#Performance

    Nothing specifc regarding multi-threading other than to use it.  Although the section on caching is probably pertinent to you.


    Caching

    To improve performance on requests to the Web services, you can statically cache the IServiceConfiguration class. In addition, monitor your WCF security token and refresh it before it expires. By refreshing the token before it expires, you will not lose the token and have to start over with authentication. To check the token, you can create a class that inherits from the OrganizationServiceProxyclass or the DiscoveryServiceProxy class, or wrap those classes in a new class. You can see an example of the first method in the ToolServiceProxies.cs and AutoRefreshSecurityToken.cs sample code files in the Tools\PluginRegistration folder of the SDK download. Another alternative method is to manually check the token before each call to the Web service.

    You should note that if you enable early bound types, you enable this for all proxies that use that IServiceConfiguration instance.

    If your application makes use of the metadata, it is recommended that you cache the metadata you have retrieved and to periodically call the RetrieveTimestampRequest message to determine if you need to refresh the cache.

     

     


    --pogo (pat)
    Thursday, April 21, 2011 8:07 PM
  • Also keep in mind that there are limits to the number of simultaneous connections that can be made to a WCF service, so you'll have to intelligently manage your thread pool.
    --pogo (pat)
    Thursday, April 21, 2011 8:15 PM