web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

AsyncOperation - Direct Creation for Async Processing of SDK messages?

(0) ShareShare
ReportReport
Posted on by

I've worked with another ERP/CRM called Netsuite and one thing I remember from using their API was that you could submit API calls either Synchronously or Asynchronously.

So for instance, you could submit a bunch of 100 Create or Update requests to the server, and as the server had bandwidth, it would process those requests Asynchronously and as a consumer of the API, you could query for progress/status of the requests at a point after submitting.

With Dynamics CRM, when I make SDK/API calls using methods on an OrganizationService such as Create or Update, those are executed Synchronously. 

Is it possible to send API requests to CRM in an Asynchronous manner? I imagine sending requests in this manner would allow them to be processed on the Async server and at a lower resource cost than the direct Synchronous requests to CRM.

One thought I had was that I could craft a new instance of an AsyncOperation object and then create that, which would then handle the Asynchronous processing of a request. I played around a bit without luck and there is no formal documentation on using this class this way.

I'm curious if anyone is aware of a way to use the API in an Asynchronous manner or if anyone has any technical thoughts on this.

*This post is locked for comments

I have the same question (0)
  • ram r Profile Picture
    on at

    You can do create or update update requests in batches using Executemultiple request in CRM. ExecuteMutlitple request can be synchronous or asynchrounous in error handling  which is controlled by two settings

    ContinueOnError:

    When true, continue processing the next request in the collection even if a fault has been returned from processing the current request in the collection. When false, do not continue processing the next request.

    ReturnResponses:

    When true, return responses from each message request processed. When false, do not return responses.

    If set to true and a request does not return a response, because that is its design, the ExecuteMultipleResponseItem for that request is set to null.

    However, even when false, the Responses collection will not be empty if errors are returned. If errors are returned, there will be one response item in the collection for each processed request that returned a fault and Fault will be set to the actual fault that occurred.

    Reference: 

    msdn.microsoft.com/.../jj863631.aspx

  • fb88 Profile Picture
    on at

    Hi Ram,

    I reviewed the reference you provided however I was unable to find any information in that document that indicates ExecuteMulitple requests are processed Asynchronously on the server-side. Since other operations that can be performed Asynchronously in CRM utilize AsyncOperation, my expectation is that if there is any way to perform Asynchronous API/SDK calls in Dynamics CRM, they will utilize that table. So I was explicitly looking for information in the document that indicated it utilized that table or was processed by the Async server itself, again I did not find those details.

  • fb88 Profile Picture
    on at

    I accidentally stumbled across this just now:

    msdn.microsoft.com/.../microsoft.xrm.sdk.messages.executeasyncrequest.aspx

    I thought that this might be the answer to my question but then I ran across this page:

    https://msdn.microsoft.com/en-us/library/gg328075.aspx#bkmk_executeasync

    It says: Currently, only the ImportSolutionRequest message can be used with the ExecuteAsync message.

  • ram r Profile Picture
    on at

    Have a look into below request,

    msdn.microsoft.com/.../microsoft.xrm.sdk.messages.executeasyncrequest.aspx

  • fb88 Profile Picture
    on at

    Hey Ram, I think I ran across that just as you posted it. In my above reply, I added some details that indicate this message is not useful for the purpose I described because documentation indicates it is only used for a single message type "ImportSolutionRequest".

  • ram r Profile Picture
    on at

    You can still send asynchronous request using multiple ways to CRM using .net framework

    1. Parallel.foreach

    2. Task.run/async

  • fb88 Profile Picture
    on at

    I agree with you that there are ways to wrap the Dynamics CRM API/SDK and in that wrapper perform asynchronous operations but those would no longer be server-side in Dynamics but rather client-side of the code execution. My specific question is about server-side execution of the requests, specifically for the performance benefit of using the Dynamics CRM Async service to process requests.

  • ram r Profile Picture
    on at

    Agreed!  AFAIK, The only request which is close to your requirement and has performance benefit is Executemultiplerequest. But it doesn't seem to be async.

  • fb88 Profile Picture
    on at

    Yeah, I utilize ExecuteMultiple often due to how fast it can process requests, especially when there is latency between the client/server.

    It is curious that they seem to have implemented what I mentioned in ExecuteAsyncRequest message but have limited it's scope to only a single message type. I wonder if they'll expand this in the future.

    I can imagine something of a hack to accomplish this, you could create an Action that takes a string parameter which could contain a serialized OrganizationRequest and register an Async plugin on that Action that has logic to deserialize/execute the Org Request sent in. That plugin code would execute via the Async service and if exceptions were encountered, I believe they would be logged to the AsyncOperation record created for that instance of the plugin executing.

    I can imagine many scenarios where I have lots of data operations I'd like to perform and perhaps I want to execute them during business hours but at a lower priority and using the resources of the Async server. So my curiosity and desire to potentially execute messages in that manner were driving this question.

    If anyone else has input on this, I'd love to hear it. Perhaps there is also an undocumented way to manually create an AsyncOperation in a manner that accomplishes this as well. I may experiment further.

  • ram r Profile Picture
    on at

    I like your thought process. Though I do not have much insight on Executemultiple requests underlying architecture, I believe it has something to do with loadbalance and async calls. I could see an setting with async keyword(ExecuteAsyncPerOrgMaxConnectionsPerServer) which restrict the concurrent calls for executemultiple requests and the performance of the request makes makes me feel that way. Lets wait for others inputs.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans