Beispiel #1
0
 internal override void OnRuntimeDescriptionChanged(Microsoft.ServiceBus.Messaging.RuntimeEntityDescription newValue)
 {
     if (newValue == null)
     {
         this.SbmpSenderBatchingEnabled = false;
     }
     else
     {
         this.RequiresDuplicateDetection = newValue.RequiresDuplicateDetection;
         if (newValue.EnableSubscriptionPartitioning)
         {
             this.EnableSubscriptionPartitioning  = true;
             this.EnableMessagePartitioning       = false;
             this.ShouldAddPartitioningHeaders    = true;
             this.BatchManager.GroupByKeySelector = new GroupByKeySelectorDelegate <BrokeredMessage>(this.SubscriptionPartitioningGroupByKeySelector);
             this.BatchManager.CalculateBatchSize = new CalculateBatchSizeDelegate <BrokeredMessage>(SbmpMessageSender.SubscriptionPartitioningCalculateSizeOfMessages);
             this.SbmpSenderBatchingEnabled       = true;
         }
         else if (!newValue.EnableMessagePartitioning)
         {
             this.EnableMessagePartitioning       = false;
             this.EnableSubscriptionPartitioning  = false;
             this.ShouldAddPartitioningHeaders    = false;
             this.BatchManager.GroupByKeySelector = null;
             this.BatchManager.CalculateBatchSize = new CalculateBatchSizeDelegate <BrokeredMessage>(SbmpMessageSender.DefaultCalculateSizeOfMessages);
             this.SbmpSenderBatchingEnabled       = true;
         }
         else
         {
             this.EnableMessagePartitioning      = true;
             this.EnableSubscriptionPartitioning = false;
             this.ShouldAddPartitioningHeaders   = true;
             if (!newValue.RequiresDuplicateDetection)
             {
                 this.BatchManager.GroupByKeySelector = new GroupByKeySelectorDelegate <BrokeredMessage>(this.MessagePartitioningKeyGroupByKeySelector);
                 this.BatchManager.CalculateBatchSize = (this.ViaSender ? new CalculateBatchSizeDelegate <BrokeredMessage>(SbmpMessageSender.MessagePartitioningViaSenderCalculateSizeOfMessages) : new CalculateBatchSizeDelegate <BrokeredMessage>(SbmpMessageSender.MessagePartitioningCalculateSizeOfMessages));
             }
             else
             {
                 this.BatchManager.GroupByKeySelector = new GroupByKeySelectorDelegate <BrokeredMessage>(this.DeDupMessagePartitioningKeyGroupByKeySelector);
                 this.BatchManager.CalculateBatchSize = (this.ViaSender ? new CalculateBatchSizeDelegate <BrokeredMessage>(SbmpMessageSender.MessagePartitioningViaSenderCalculateSizeOfMessages) : new CalculateBatchSizeDelegate <BrokeredMessage>(SbmpMessageSender.DeDupMessagePartitioningCalculateSizeOfMessages));
             }
             this.SbmpSenderBatchingEnabled = true;
         }
     }
     base.OnRuntimeDescriptionChanged(newValue);
 }
        public static void AddOrUpdate(string entityAddress, RuntimeEntityDescription newEntityDescription)
        {
            if (string.IsNullOrWhiteSpace(entityAddress))
            {
                throw new ArgumentException(SRCore.ArgumentNullOrEmpty("entityAddress"));
            }
            if (newEntityDescription == null)
            {
                throw new ArgumentNullException("newEntityDescription");
            }
            MemoryCache              memoryCaches              = RuntimeEntityDescriptionCache.entityDescriptionCache;
            string                   upperInvariant            = entityAddress.ToUpperInvariant();
            DateTimeOffset           utcNow                    = DateTimeOffset.UtcNow;
            RuntimeEntityDescription enableMessagePartitioning = (RuntimeEntityDescription)memoryCaches.AddOrGetExisting(upperInvariant, newEntityDescription, utcNow.Add(RuntimeEntityDescriptionCache.cacheEntryTtl), null);

            if (enableMessagePartitioning != null)
            {
                enableMessagePartitioning.EnableMessagePartitioning = newEntityDescription.EnableMessagePartitioning;
            }
        }
 public static bool TryGet(string entityAddress, out RuntimeEntityDescription entityDescription)
 {
     entityDescription = (RuntimeEntityDescription)RuntimeEntityDescriptionCache.entityDescriptionCache.Get(entityAddress.ToUpperInvariant(), null);
     return(entityDescription != null);
 }