/// <summary> /// Callback of the CloudQueue.BeginAddMessage method. /// </summary> /// <param name="ar">async result</param> /// <remarks> /// Notice: This method doesn't throw exception. It invokes callback /// and pass exception to it in case exception occurs. /// </remarks> private void BeginAddMessageCallback(IAsyncResult ar) { BrokerTracing.TraceVerbose("[AzureServiceClient].BeginAddMessageCallback: Enter callback method of BeginAddMessage."); var reliableState = ar.AsyncState as ReliableQueueClient.ReliableState; QueueAsyncResult asyncResult = reliableState.State as QueueAsyncResult; Debug.Assert(asyncResult != null, "reliableState.State must be a QueueAsyncResult."); try { BrokerTracing.TraceVerbose( "[AzureServiceClient].BeginAddMessageCallback: Try to complete adding message {0}", asyncResult.MessageId); asyncResult.StorageClient.EndAddMessage(ar); } catch (StorageException e) { BrokerTracing.TraceError( "[AzureServiceClient].BeginAddMessageCallback: Failed to complete adding message {0}, {1}", asyncResult.MessageId, e.ToString()); if (BurstUtility.IsQueueNotFound(e)) { // StorageException happens here when want to add request // messages, so it must be request queue not found. Handle // the outstanding messages, which are already sent to // request queue, but maybe not got by proxy. And should // consider the multi request queue case when there are // multi azure deployments. this.manager.HandleInvalidRequestQueue(new RequestStorageException(e), this.requestStorageClient.QueueName); } this.manager.CompleteCallback(asyncResult, null, new RequestStorageException(e)); } catch (Exception e) { BrokerTracing.TraceError( "[AzureServiceClient].BeginAddMessageCallback: Failed to complete adding message {0}, {1}", asyncResult.MessageId, e.ToString()); this.manager.CompleteCallback(asyncResult, null, e); } }
/// <summary> /// Handle the invalid response queue. /// </summary> /// <param name="e"> /// exception occurred when access the response queue /// </param> private void HandleInvalidResponseQueue(StorageException e) { BrokerTracing.TraceWarning( "[ResponseQueueManager].HandleInvalidResponseQueue: Exception occurs when access response queue, {0}, {1}, {2}", BurstUtility.GetStorageErrorCode(e), e, this.responseStorageName); if (BurstUtility.IsQueueNotFound(e)) { // Current method is called once, so only have following trace once. BrokerTracing.EtwTrace.LogQueueNotExist(this.sessionId, this.responseStorageName); this.azureQueueManager.TriggerCallbackForInvalidResponseQueue( new ResponseStorageException(e, this.responseStorageName)); } }
/// <summary> /// Handle the invalid request queue. /// </summary> /// <param name="e"> /// exception occurred when access the response queue /// </param> /// <param name="requestQueueName"> /// request queue name /// </param> public void HandleInvalidRequestQueue(StorageException e, string requestQueueName) { BrokerTracing.TraceWarning( "[AzureQueueManager].HandleInvalidRequestQueue: Exception occurs when access request queue, {0}, {1}", BurstUtility.GetStorageErrorCode(e), e); if (BurstUtility.IsQueueNotFound(e)) { if (Interlocked.CompareExchange(ref this.requestQueueExist, 0, 1) == 1) { BrokerTracing.EtwTrace.LogQueueNotExist(this.sessionId, requestQueueName); } this.TriggerCallbackForInvalidRequestQueue(requestQueueName, e); } }
/// <summary> /// Invoke invalidQueueHandler if failed to access the queue. /// </summary> /// <remarks> /// Notice: Only handle the case that queue is not found now. May /// add more error handlings for specific queue issues if necessary. /// </remarks> /// <param name="e">exception happens when access the queue</param> private void HandleInvalidQueue(StorageException e) { TraceUtils.TraceError( "MessageRetriever.Worker", "HandleInvalidQueue", "StorageException, worker {0}, queue {1}, error code {2}, {3}", this.workerId, this.queue.Name, BurstUtility.GetStorageErrorCode(e), e); if (BurstUtility.IsQueueNotFound(e)) { // Invoke invalidQueueHandler if the exception indicates // that the queue is not found. if (this.invalidQueueHandler != null) { this.invalidQueueHandler(e); } } }
/// <summary> /// Invoke invalidQueueHandler if failed to access the queue. /// </summary> /// <remarks> /// Notice: Only handle the case that queue is not found now. May /// add more error handlings for specific queue issues if necessary. /// </remarks> /// <param name="e">exception happens when access the queue</param> private void HandleInvalidQueue(StorageException e) { SessionBase.TraceSource.TraceEvent( TraceEventType.Error, 0, "StorageException, worker {0}, queue {1}, error code {2}, {3}", this.workerId, this.queue.Name, BurstUtility.GetStorageErrorCode(e), e); if (BurstUtility.IsQueueNotFound(e)) { // Invoke invalidQueueHandler if the exception indicates // that the queue is not found. if (this.invalidQueueHandler != null) { this.invalidQueueHandler(e); } } }