コード例 #1
0
 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);
                                });
 }
コード例 #2
0
ファイル: QueueUris.cs プロジェクト: awithy/AzureStorage
 public override string ToUriString()
 {
     var messagesBase = new QueueUri(_accountName, _queueName.ToString()).ToUriString() + "/messages";
     var uriParams = _GetUriParams();
     return messagesBase + uriParams;
 }
コード例 #3
0
ファイル: QueueUris.cs プロジェクト: awithy/AzureStorage
 public QueueMessageUri(QueueUri queueUri, QueueMessage queueMessage, TimeSpan? visibilityTimeout)
 {
     _queueUri = queueUri;
     _queueMessage = queueMessage;
     _visibilityTimeout = visibilityTimeout;
 }
コード例 #4
0
ファイル: QueueUris.cs プロジェクト: awithy/AzureStorage
 public override string ToUriString()
 {
     var uriString = new QueueUri(_accountName, _queueName.ToString()).ToUriString() + "/messages";
     uriString += _GetUriParams();
     return uriString;
 }
コード例 #5
0
 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);
                                    });
 }
コード例 #6
0
 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);
                             });
 }
コード例 #7
0
 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);
                             });
 }
コード例 #8
0
 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;
                             });
 }
コード例 #9
0
 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);
                             });
 }
コード例 #10
0
 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);
                             });
 }
コード例 #11
0
 public Task PutMessage(QueueUri queueUri, string message)
 {
     return PutMessage(queueUri, message, new DefaultPutMessageOptions());
 }
コード例 #12
0
 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();
                             });
 }
コード例 #13
0
 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);
                                    });
 }
コード例 #14
0
 public Task<QueueMessage> GetMessageWithVisibilityTimeout(QueueUri queueUri, TimeSpan visibilityTimeout)
 {
     return _GetMessages(queueUri, 1, visibilityTimeout)
         .ContinueWith(x => x.Result.FirstOrDefault());
 }
コード例 #15
0
 public Task<IEnumerable<QueueMessage>> Get32Messages(QueueUri queueUri)
 {
     return _GetMessages(queueUri, 32, _defaultVisibilityTimeout);
 }