public GetEnvelopeResult TryGetMessage() { FileInfo message; try { message = _queue.EnumerateFiles().FirstOrDefault(); } catch (Exception ex) { SystemObserver.Notify(new FailedToReadMessage(ex, _queueName)); return(GetEnvelopeResult.Error()); } if (null == message) { return(GetEnvelopeResult.Empty); } try { var buffer = File.ReadAllBytes(message.FullName); var unpacked = new MessageTransportContext(message, buffer, _queueName); return(GetEnvelopeResult.Success(unpacked)); } catch (IOException ex) { // this is probably sharing violation, no need to // scare people. if (!IsSharingViolation(ex)) { SystemObserver.Notify(new FailedToAccessStorage(ex, _queue.Name, message.Name)); } return(GetEnvelopeResult.Retry); } catch (Exception ex) { SystemObserver.Notify(new MessageInboxFailed(ex, _queue.Name, message.FullName)); // new poison details return(GetEnvelopeResult.Retry); } }
public GetEnvelopeResult TryGetMessage() { CloudQueueMessage message; try { message = _queue.GetMessage(_visibilityTimeout); } catch (ThreadAbortException) { // we are stopping return(GetEnvelopeResult.Empty); } catch (Exception ex) { SystemObserver.Notify(new FailedToReadMessage(ex, _queueName)); return(GetEnvelopeResult.Error()); } if (null == message) { return(GetEnvelopeResult.Empty); } try { var unpacked = DownloadPackage(message); return(GetEnvelopeResult.Success(unpacked)); } catch (StorageClientException ex) { SystemObserver.Notify(new FailedToAccessStorage(ex, _queue.Name, message.Id)); return(GetEnvelopeResult.Retry); } catch (Exception ex) { SystemObserver.Notify(new MessageInboxFailed(ex, _queue.Name, message.Id)); // new poison details _posionQueue.Value.AddMessage(message); _queue.DeleteMessage(message); return(GetEnvelopeResult.Retry); } }