public Task ClearMessages(QueueUri queueUri)
 {
     var messagesUri = new QueueMessagesUri(queueUri.Account, queueUri.QueueName.ToString(), null, null);
     var result = _GetHttpClientAdapter(queueUri.Account).Delete(messagesUri);
     return result.ContinueWith(x =>
                                {
                                    if (x.Result.StatusCode != HttpStatusCode.NoContent)
                                        throw new AzureStorageException("ClearMessages", messagesUri,
                                                                        x.Result);
                                });
 }
Example #2
0
 public override string ToUriString()
 {
     var messagesBase = new QueueUri(_accountName, _queueName.ToString()).ToUriString() + "/messages";
     var uriParams = _GetUriParams();
     return messagesBase + uriParams;
 }
Example #3
0
 public QueueMessageUri(QueueUri queueUri, QueueMessage queueMessage, TimeSpan? visibilityTimeout)
 {
     _queueUri = queueUri;
     _queueMessage = queueMessage;
     _visibilityTimeout = visibilityTimeout;
 }
Example #4
0
 public override string ToUriString()
 {
     var uriString = new QueueUri(_accountName, _queueName.ToString()).ToUriString() + "/messages";
     uriString += _GetUriParams();
     return uriString;
 }
 public Task DeleteMessage(QueueUri queueUri, QueueMessage queueMessage)
 {
     var queueMessageUri = new QueueMessageUri(queueUri, queueMessage, null);
     var result = _GetHttpClientAdapter(queueUri.Account).Delete(queueMessageUri);
     return result.ContinueWith(x =>
                                    {
                                        if (x.Result.StatusCode != HttpStatusCode.NoContent)
                                            throw new AzureStorageException("DeleteMessage", queueMessageUri, x.Result);
                                    });
 }
 public Task CreateIfNotExist(QueueUri queueUri)
 {
     var result = _GetHttpClientAdapter(queueUri.Account).Put(queueUri);
     return result.ContinueWith(x =>
                             {
                                 if (x.Result.StatusCode != HttpStatusCode.Created &&
                                     x.Result.StatusCode != HttpStatusCode.NoContent)
                                     throw new AzureStorageException("CreateIfNotExist", queueUri, x.Result);
                             });
 }
 public Task<UpdateMessageResult> UpdateMessage(QueueUri queueUri, QueueMessage queueMessage, string newContent, TimeSpan newVisibilityTimeout)
 {
     var queueMessageUri = new QueueMessageUri(queueUri, queueMessage, newVisibilityTimeout);
     var messageContent = _queueSerialization.GetMessageContent(newContent);
     var result = _GetHttpClientAdapter(queueUri.Account).Put(queueMessageUri, messageContent);
     return result.ContinueWith(x =>
                             {
                                 if (x.Result.StatusCode != HttpStatusCode.NoContent)
                                     throw new AzureStorageException("UpdateMessage", queueMessageUri, x.Result);
                                 return _ParseUpdateMessageResultHeaders(x.Result);
                             });
 }
 private Task<IEnumerable<QueueMessage>> _GetMessages(QueueUri queueUri, int numOfMessages, TimeSpan visibilityTimeout)
 {
     var uri = new QueueMessagesUri(queueUri.Account, queueUri.QueueName.ToString(), numOfMessages, visibilityTimeout);
     var result = _GetHttpClientAdapter(queueUri.Account).Get(uri);
     return result.ContinueWith(x =>
                             {
                                 if (x.Result.StatusCode != HttpStatusCode.OK)
                                     throw new AzureStorageException("GetMessage/Get32Messages", uri, x.Result);
                                 var messages = _queueSerialization.ParseMessages(x.Result);
                                 return messages;
                             });
 }
 public Task PutMessage(QueueUri queueUri, string message, PutMessageOptions putMessageOptions)
 {
     var uri = new PutQueueMessagesUri(queueUri.Account, queueUri.QueueName.ToString(), putMessageOptions);
     var messageContent = _queueSerialization.GetMessageContent(message);
     var result = _GetHttpClientAdapter(queueUri.Account).Post(uri, messageContent);
     return result.ContinueWith(x =>
                             {
                                 if (x.Result.StatusCode != HttpStatusCode.Created)
                                     throw new AzureStorageException("PutMessage", uri, x.Result);
                             });
 }
 public Task PutQueueMetadata(QueueUri queueUri, IEnumerable<QueueMetadataNameValuePair> userMetadata)
 {
     var queueMetadataUri = new QueueMetadataUri(queueUri.Account, queueUri.QueueName.ToString());
     var additionalHeaders = userMetadata.Select(x => new NameValueHeaderValue("x-ms-meta-" + x.Name, x.Value));
     var result = _GetHttpClientAdapter(queueUri.Account).Put(queueMetadataUri, additionalHeaders);
     return result.ContinueWith(x =>
                             {
                                 if (x.Result.StatusCode != HttpStatusCode.NoContent)
                                     throw new AzureStorageException("PutQueueMetadata", queueMetadataUri, x.Result);
                             });
 }
 public Task PutMessage(QueueUri queueUri, string message)
 {
     return PutMessage(queueUri, message, new DefaultPutMessageOptions());
 }
 public Task<QueueMessage> PeekMessage(QueueUri queueUri)
 {
     var uri = new QueueMessagesUri(queueUri.Account, queueUri.QueueName.ToString(), 1, null, true);
     var result = _GetHttpClientAdapter(queueUri.Account).Get(uri);
     return result.ContinueWith(x =>
                             {
                                 if (x.Result.StatusCode != HttpStatusCode.OK)
                                     throw new AzureStorageException("PeekMessage", uri, x.Result);
                                 var messages = _queueSerialization.ParseMessages(x.Result);
                                 return messages.FirstOrDefault();
                             });
 }
 public Task<QueueMetadata> GetQueueMetadata(QueueUri queueUri)
 {
     var queueMetadataUri = new QueueMetadataUri(queueUri.Account, queueUri.QueueName.ToString());
     var result = _GetHttpClientAdapter(queueUri.Account).Get(queueMetadataUri);
     return result.ContinueWith(x =>
                                    {
                                        if (x.Result.StatusCode != HttpStatusCode.OK)
                                            throw new AzureStorageException("GetQueueMetadata", queueMetadataUri, x.Result);
                                        return _ParseQueueMetadataResponse(x.Result);
                                    });
 }
 public Task<QueueMessage> GetMessageWithVisibilityTimeout(QueueUri queueUri, TimeSpan visibilityTimeout)
 {
     return _GetMessages(queueUri, 1, visibilityTimeout)
         .ContinueWith(x => x.Result.FirstOrDefault());
 }
 public Task<IEnumerable<QueueMessage>> Get32Messages(QueueUri queueUri)
 {
     return _GetMessages(queueUri, 32, _defaultVisibilityTimeout);
 }