public IAsyncResult BeginDeleteMessage(IQueueMessageReceipt receipt, AsyncCallback callback, object state) { AsyncIteratorContext <bool> asyncIteratorContext = new AsyncIteratorContext <bool>("QueueContainer.DeleteMessage", callback, state); asyncIteratorContext.Begin(this.DeleteMessageImpl(receipt, asyncIteratorContext)); return(asyncIteratorContext); }
protected override PoppedMessage GetPoppedMessageInfoFromReceipt(IQueueMessageReceipt popreceipt) { Receipt receipt = (Receipt)popreceipt; Guid messageId = receipt.MessageId; return(new PoppedMessage(messageId.ToString(), null, DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc), DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc), receipt.VisibilityStart, 1, Receipt.Serialize(receipt))); }
public IAsyncResult BeginUpdateMessage(IQueueMessageReceipt receipt, byte[] body, TimeSpan visibilityTimeout, TimeSpan?timeToLive, AsyncCallback callback, object state) { AsyncIteratorContext <IQueueMessageReceipt> asyncIteratorContext = new AsyncIteratorContext <IQueueMessageReceipt>("QueueContainer.UpdateMessage", callback, state); asyncIteratorContext.Begin(this.UpdateMessageImpl(receipt, body, visibilityTimeout, timeToLive, asyncIteratorContext)); return(asyncIteratorContext); }
private IEnumerator <IAsyncResult> DeleteMessageImpl(IQueueMessageReceipt queueMessageReceipt, AsyncIteratorContext <bool> context) { IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <bool>((TimeSpan remaining) => { bool flag; using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer queueContainer = this.LoadQueueContainer(dbContext); context.ResultData = false; Receipt receipt = (Receipt)queueMessageReceipt; Guid messageId = receipt.MessageId; DateTime visibilityStart = receipt.VisibilityStart; QueueMessage queueMessage = ( from m in dbContext.QueueMessages where (m.AccountName == this._queue.AccountName) && (m.QueueName == this._queue.QueueName) && (m.VisibilityStartTime == visibilityStart) && (m.MessageId == messageId) select m).FirstOrDefault <QueueMessage>(); if (queueMessage == null) { throw new MessageNotFoundException(); } dbContext.QueueMessages.DeleteOnSubmit(queueMessage); dbContext.SubmitChanges(); this._queue = queueContainer; flag = true; } return(flag); }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbQueueContainer.DeleteMessageImpl")); yield return(asyncResult); context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <bool>(asyncResult); }
private IEnumerator <IAsyncResult> UpdateMessageImpl(IQueueMessageReceipt receipt, byte[] body, TimeSpan visibilityTimeout, TimeSpan?timeToLive, AsyncIteratorContext <IQueueMessageReceipt> context) { IAsyncResult asyncResult; RemainingTime remainingTime = new RemainingTime(base.Timeout); try { this.InternalContainer.Timeout = StorageStampHelpers.AdjustTimeoutRange(remainingTime); } catch (Exception exception) { StorageStamp.TranslateException(exception); throw; } try { asyncResult = this.InternalContainer.BeginGetProperties(ContainerPropertyNames.None, null, context.GetResumeCallback(), context.GetResumeState("QueueContainer.GetMessageImpl")); } catch (Exception exception1) { StorageStamp.TranslateException(exception1); throw; } yield return(asyncResult); try { this.InternalContainer.EndGetProperties(asyncResult); } catch (Exception exception2) { StorageStamp.TranslateException(exception2); throw; } try { this.InternalContainer.Timeout = remainingTime; asyncResult = this.InternalContainer.BeginUpdateMessage(receipt, body, visibilityTimeout, timeToLive, context.GetResumeCallback(), context.GetResumeState("QueueContainer.GetMessageImpl")); } catch (Exception exception3) { StorageStamp.TranslateException(exception3); throw; } yield return(asyncResult); try { context.ResultData = this.InternalContainer.EndUpdateMessage(asyncResult); } catch (Exception exception4) { StorageStamp.TranslateException(exception4); throw; } }
protected override IEnumerator <IAsyncResult> DeleteMessageImpl(IAccountIdentifier identity, string account, string queue, string messageId, byte[] popReceipt, TimeSpan?timeout, RequestContext requestContext, AsyncIteratorContext <NoResults> context) { RemainingTime remainingTime = new RemainingTime(timeout); SASAuthorizationParameters sASAuthorizationParameter = new SASAuthorizationParameters() { SupportedSasTypes = SasType.ResourceSas | SasType.AccountSas, SignedResourceType = SasResourceType.Object, SignedPermission = SASPermission.Process }; SASAuthorizationParameters sASAuthorizationParameter1 = sASAuthorizationParameter; NephosAssertionException.Assert(popReceipt != null); IAsyncResult asyncResult = this.BeginGetQueue(identity, account, queue, PermissionLevel.Delete, sASAuthorizationParameter1, remainingTime, requestContext, context.GetResumeCallback(), context.GetResumeState("QueueManager.DeleteMessageImpl")); yield return(asyncResult); IQueueContainer operationStatus = this.EndGetQueue(asyncResult); if (requestContext != null) { operationStatus.OperationStatus = requestContext.OperationStatus; } try { Guid guid = new Guid(messageId); } catch (Exception exception) { throw new MessageNotFoundException("Invalid message name", exception); } IQueueMessageReceipt queueMessageReceipt = this.DecodeReceipt(popReceipt, new Guid(messageId)); operationStatus.Timeout = remainingTime; asyncResult = operationStatus.BeginDeleteMessage(queueMessageReceipt, context.GetResumeCallback(), context.GetResumeState("QueueManager.DeleteMessageImpl")); yield return(asyncResult); bool flag = operationStatus.EndDeleteMessage(asyncResult); IStringDataEventStream verboseDebug = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug; object[] str = new object[] { flag, queueMessageReceipt.ToString() }; verboseDebug.Log("DeleteMessage response: status={0} message={1}", str); if (!flag) { throw new MessageNotFoundException("The message could not be deleted or pop receipt invalid."); } }
private IEnumerator <IAsyncResult> UpdateMessageImpl(IQueueMessageReceipt queueMessageReceipt, byte[] body, TimeSpan visibilityTimeout, TimeSpan?timeToLive, AsyncIteratorContext <IQueueMessageReceipt> context) { IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <IQueueMessageReceipt>((TimeSpan remaining) => { IQueueMessageReceipt receipt; using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext()) { Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer queueContainer = this.LoadQueueContainer(dbContext); this._queue = queueContainer; QueueMessage queueMessage = ( from m in dbContext.QueueMessages where (m.AccountName == this._queue.AccountName) && (m.QueueName == this._queue.QueueName) && (m.MessageId == ((Receipt)queueMessageReceipt).MessageId) && (m.VisibilityStartTime == ((Receipt)queueMessageReceipt).VisibilityStart) select m).FirstOrDefault <QueueMessage>(); if (queueMessage == null) { throw new MessageNotFoundException(); } DateTime utcNow = DateTime.UtcNow; QueueMessage queueMessage1 = new QueueMessage() { AccountName = queueMessage.AccountName, QueueName = queueMessage.QueueName, VisibilityStartTime = utcNow.Add(visibilityTimeout), MessageId = queueMessage.MessageId, ExpiryTime = queueMessage.ExpiryTime, InsertionTime = queueMessage.InsertionTime, DequeueCount = queueMessage.DequeueCount, Data = body ?? queueMessage.Data }; dbContext.QueueMessages.DeleteOnSubmit(queueMessage); dbContext.QueueMessages.InsertOnSubmit(queueMessage1); dbContext.SubmitChanges(); receipt = new Receipt() { MessageId = ((Receipt)queueMessageReceipt).MessageId, VisibilityStart = queueMessage1.VisibilityStartTime, DequeueCount = queueMessage1.DequeueCount }; } return(receipt); }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbQueueContainer.UpdateMessage")); yield return(asyncResult); context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <IQueueMessageReceipt>(asyncResult); }
protected override IEnumerator <IAsyncResult> UpdateMessageImpl(IAccountIdentifier identity, string account, string queue, string messageId, byte[] popReceipt, byte[] body, TimeSpan visibilityTimeout, TimeSpan?timeout, RequestContext requestContext, AsyncIteratorContext <PoppedMessage> context) { Guid guid; RemainingTime remainingTime = new RemainingTime(timeout); SASAuthorizationParameters sASAuthorizationParameter = new SASAuthorizationParameters() { SupportedSasTypes = SasType.ResourceSas | SasType.AccountSas, SignedResourceType = SasResourceType.Object, SignedPermission = SASPermission.Update }; SASAuthorizationParameters sASAuthorizationParameter1 = sASAuthorizationParameter; IAsyncResult asyncResult = this.BeginGetQueue(identity, account, queue, PermissionLevel.Write, sASAuthorizationParameter1, remainingTime, requestContext, context.GetResumeCallback(), context.GetResumeState("QueueManager.UpdateMessageImpl")); yield return(asyncResult); IQueueContainer operationStatus = this.EndGetQueue(asyncResult); if (requestContext != null) { operationStatus.OperationStatus = requestContext.OperationStatus; } operationStatus.Timeout = remainingTime; try { guid = new Guid(messageId); } catch (Exception exception) { throw new MessageNotFoundException("Invalid message name", exception); } IQueueMessageReceipt queueMessageReceipt = this.DecodeReceipt(popReceipt, guid); TimeSpan? nullable = null; asyncResult = operationStatus.BeginUpdateMessage(queueMessageReceipt, body, visibilityTimeout, nullable, context.GetResumeCallback(), context.GetResumeState("QueueManager.UpdateMessageImpl")); yield return(asyncResult); IQueueMessageReceipt queueMessageReceipt1 = operationStatus.EndUpdateMessage(asyncResult); context.ResultData = this.GetPoppedMessageInfoFromReceipt(queueMessageReceipt1); }
IAsyncResult Microsoft.Cis.Services.Nephos.Common.Storage.IQueueOperations.BeginUpdateMessage(IQueueMessageReceipt receipt, byte[] body, TimeSpan visibilityTimeout, TimeSpan?timeToLive, AsyncCallback callback, object state) { AsyncIteratorContext <IQueueMessageReceipt> asyncIteratorContext = new AsyncIteratorContext <IQueueMessageReceipt>("DbQueueContainer.UpdateMessage", callback, state); asyncIteratorContext.Begin(this.UpdateMessageImpl(receipt, body, visibilityTimeout, timeToLive, asyncIteratorContext)); return(asyncIteratorContext); }
IAsyncResult Microsoft.Cis.Services.Nephos.Common.Storage.IQueueOperations.BeginDeleteMessage(IQueueMessageReceipt queueMessageReceipt, AsyncCallback callback, object state) { AsyncIteratorContext <bool> asyncIteratorContext = new AsyncIteratorContext <bool>("DbQueueContainer.DeleteMessage", callback, state); asyncIteratorContext.Begin(this.DeleteMessageImpl(queueMessageReceipt, asyncIteratorContext)); return(asyncIteratorContext); }
protected abstract PoppedMessage GetPoppedMessageInfoFromReceipt(IQueueMessageReceipt popreceipt);