Recently i am experiencing some SharePoint schedule not able to wake up after the time was elapsed even though i have applied the Microsoft KB932394 patch that fixes a bug related to the timer. After doing some investigations, i discovered that the main root cause was because of the SMTP server not able to response when multiple mails were sent simultinousely. This has caused the SharePoint workflow process to be blocked. I solved this problem by converting the workflow to a asynchronous process and by adding some retry logics that can help to resend an unsent email. Below is the code that i applied:
374 //Assign a callback function
375 AsyncCallback callback = new AsyncCallback(CallBack);
376 //Create a delegate that trigger the send mail function
377 SendEmailHandler handler = new SendEmailHandler(SendEmailUsingSmtp);
378 //Call the function with all the related parameters
379 IAsyncResult result = handler.BeginInvoke(this.SmtpServer, this.Port, this.From, callback, null);
380 //Wait for 30 seconds, else timeout
381 result.AsyncWaitHandle.WaitOne(new TimeSpan(0, 0, 30), true);
382 //end of function invoke.
383 handler.EndInvoke(result);
No comments:
Post a Comment