Example #1
0
        public static void ProcessMessage(QueueEnvelope envelope, bool reportEnvelopeError = true)
        {
            try
            {
                InformationContext.Current.InitializeCloudStorageAccess(envelope.ActiveContainerName);
                if (envelope.SingleOperation != null)
                {
                    ProcessSingleOperation(envelope.SingleOperation);
                }
                if (envelope.OrderDependentOperationSequence != null)
                {
                    Exception firstException = null;
                    //envelope.OrderDependentOperationSequence.CollectionContent.ForEach(ProcessSingleOperation);
                    foreach (var singleOperation in envelope.OrderDependentOperationSequence.CollectionContent)
                    {
                        try
                        {
                            ProcessSingleOperation(singleOperation);
                        } catch (Exception ex)
                        {
                            firstException = ex;
                            ErrorSupport.ReportException(ex);
                        }
                    }
                    if (firstException != null)
                    {
                        throw firstException;
                    }
                }
            }
            catch (Exception ex)
            {
                if (reportEnvelopeError)
                {
                    ErrorSupport.ReportEnvelopeWithException(envelope, ex);
                }
                throw;
            } finally
            {
                InformationContext.ProcessAndClearCurrent();
            }

            counter++;
            if (counter >= 1000)
            {
                QueueSupport.ReportStatistics("Processed " + counter + " messages...");
                counter = 0;
            }
        }
Example #2
0
 public static bool ProcessOwnerSubscriptionChains(IContainerOwner lockedOwner, string acquiredEtag, string containerName)
 {
     try
     {
         if (containerName != null)
         {
             InformationContext.Current.InitializeCloudStorageAccess(containerName: containerName);
         }
         string[]     blobs        = SubscribeSupport.GetChainRequestList(lockedOwner);
         var          chainContent = blobs.Select(blob => StorageSupport.RetrieveInformation(blob, typeof(SubscriptionChainRequestContent))).Cast <SubscriptionChainRequestContent>().ToArray();
         const double invalidSubscriptionSubmissionTimeInSeconds = 600;
         if (chainContent.Any(item => item.SubmitTime < DateTime.UtcNow.AddSeconds(-invalidSubscriptionSubmissionTimeInSeconds)))
         {
             return(false);
         }
         WorkerSupport.ExecuteSubscriptionChains(chainContent);
         foreach (string blob in blobs)
         {
             StorageSupport.DeleteBlob(blob);
         }
     }
     catch (Exception ex)
     {
         ErrorSupport.ReportException(ex);
         throw;
     }
     finally
     {
         SubscribeSupport.ReleaseChainLock(lockedOwner, acquiredEtag);
         if (containerName != null)
         {
             InformationContext.ProcessAndClearCurrent();
         }
     }
     counter++;
     if (counter >= 1000)
     {
         QueueSupport.ReportStatistics("Processed " + counter + " messages...");
         counter = 0;
     }
     return(true);
 }