我使用DelayQueue存储项目。在某些并发情况下,消费者无法获得任何物品。下面列出了代码示例。任何提示都会有所帮助。
private void SelfTransferCompleted(IAsyncResult asyncResult)
{
Exception exceptionCaught = null;
// bool exceptionEncountered = true;
try
{
_flow.Call.EndTransfer(asyncResult);
//Self Transfer has completed. successfully.
exceptionEncountered = false;
LogHelper.Log(LogTarget.FileEvent, "IVR Menu Ended self tranfer for call>" +_flow.Call.CallId);
// cleaning up atten
string sqlstring = "update astsxqueue set uniqueid ='" + _server.b2bCallDelId + "' where uniqueid='" + _flow.Call.CallId + "';";
LogHelper.Log(LogTarget.FileEvent, sqlstring);
_server.mconnector.Mysqlqueryruner(sqlstring);
}
catch (OperationTimeoutException orte)
{
LogHelper.Log(LogTarget.FileEvent, "IVR SelfTransferCompleted Operation Timeout Exception: " + orte.ToString(), 2);
exceptionCaught = orte;
exceptionEncountered = true;
LogHelper.Log(LogTarget.FileEvent, "IVR SelfTransferCompleted Trying to transfer to other agent...", 2);
RetrieveCallAfterTransferFailure();
LogHelper.Log(LogTarget.FileEvent, "IVR SelfTransferCompleted Waiting for transfer to complete...");
_server._waitForTransferComplete.WaitOne();
LogHelper.Log(LogTarget.FileEvent, "IVR SelfTransferCompleted Transfer completed.");
}
catch (FailureResponseException frte)
{
LogHelper.Log(LogTarget.FileEvent, "IVR SelfTransferCompleted Failure Exception = {0}" + frte.ToString(), 2);
exceptionCaught = frte;
exceptionEncountered = true;
LogHelper.Log(LogTarget.FileEvent, "IVR SelfTransferCompleted Trying to transfer to other agent...", 2);
RetrieveCallAfterTransferFailure();
LogHelper.Log(LogTarget.FileEvent, "Waiting for transfer to complete...");
_server._waitForTransferComplete.WaitOne();
LogHelper.Log(LogTarget.FileEvent, "Transfer completed.");
}
catch (RealTimeException rte)
{
LogHelper.Log(LogTarget.FileEvent, "IVR SelfTransferCompleted Realtime Exception = {0}" + rte.ToString(),2);
exceptionCaught = rte;
exceptionEncountered = true;
LogHelper.Log(LogTarget.FileEvent, "IVR SelfTransferCompleted Trying to transfer to other agent...", 2);
RetrieveCallAfterTransferFailure();
LogHelper.Log(LogTarget.FileEvent, "IVR Call is retreived waiting a bit...", 2);
Thread.Sleep(2000);
LogHelper.Log(LogTarget.FileEvent, "Self Transfer Call flow hold status is :>" + _flow.HoldStatus);
LogHelper.Log(LogTarget.FileEvent, "IVR Call is retreived time passed...", 2);
RetrieveCallAfterTransferFailure();
LogHelper.Log(LogTarget.FileEvent, "Self Transfer Call flow hold status is :>" + _flow.HoldStatus);
CallAgain();
// _flow.EndHold(null);
// _speechSynthesizer.Speak("We did not get to a green agent. Please retry your option!"); //TEXT TO SPEEECH!
// SpeakMenuOptions();
// toneController.ToneReceived += toneController_ToneReceived;
// Wait for the call to complete the transfer.
LogHelper.Log(LogTarget.FileEvent, "Waiting for transfer to complete...");
//_server._waitForTransferComplete.Set();
LogHelper.Log(LogTarget.FileEvent, "Transfer completed.");
}
}