Example #1
0
        private IList <SbQueue> BuildQueueList(ISbManager SbManager, string QueueName)
        {
            IList <SbQueue>          result = new List <SbQueue>();
            IList <QueueDescription> queues = new List <QueueDescription>();

            if (QueueName != null)
            {
                queues.Add(SbManager.GetQueueByName(QueueName));
            }
            else
            {
                queues = SbManager.GetAllQueues();
            }

            foreach (var queue in queues)
            {
                QueueRuntimeInfo queueRuntimeInfo = SbManager.GetQueueRuntimeInfo(queue.Path);

                result.Add(new SbQueue
                {
                    Name                  = queue.Path,
                    ActiveMessages        = queueRuntimeInfo.MessageCountDetails.ActiveMessageCount,
                    DeadLetteredMessages  = queueRuntimeInfo.MessageCountDetails.DeadLetterMessageCount,
                    ScheduledMessageCount = queueRuntimeInfo.MessageCountDetails.ScheduledMessageCount
                });
            }

            return(result);
        }
Example #2
0
        private IList <SbTopic> BuildTopicList(ISbManager SbManager, string TopicName)
        {
            IList <SbTopic>          result = new List <SbTopic>();
            IList <TopicDescription> topics = new List <TopicDescription>();

            if (TopicName != null)
            {
                topics.Add(SbManager.GetTopicByName(TopicName));
            }
            else
            {
                topics = SbManager.GetAllTopics();
            }

            foreach (var topic in topics)
            {
                IList <SubscriptionDescription> subscriptions = SbManager.GetAllSubscriptions(topic.Path);
                TopicRuntimeInfo topicRuntimeInfo             = SbManager.GetTopicRuntimeInfo(topic.Path);

                result.Add(new SbTopic
                {
                    TopicName         = topic.Path,
                    Subscriptions     = subscriptions.Select(sub => sub.SubscriptionName).ToList(),
                    ScheduledMessages = topicRuntimeInfo.MessageCountDetails.ScheduledMessageCount
                });
            }

            return(result);
        }
Example #3
0
        private IList <SbSubscription> BuildSubscriptionList(ISbManager sbManager, string TopicName, string SubscriptionName)
        {
            IList <SbSubscription>          result        = new List <SbSubscription>();
            IList <SubscriptionDescription> subscriptions = new List <SubscriptionDescription>();

            if (SubscriptionName != null)
            {
                subscriptions.Add(sbManager.GetSubscriptionByName(TopicName, SubscriptionName));
            }
            else
            {
                subscriptions = sbManager.GetAllSubscriptions(TopicName);
            }

            foreach (var subscription in subscriptions)
            {
                SubscriptionRuntimeInfo subscriptionRuntimeInfo = sbManager.GetSubscriptionRuntimeInfo(TopicName, subscription.SubscriptionName);

                result.Add(new SbSubscription
                {
                    Name                 = subscription.SubscriptionName,
                    Topic                = subscription.TopicPath,
                    ActiveMessages       = subscriptionRuntimeInfo.MessageCountDetails.ActiveMessageCount,
                    DeadLetteredMessages = subscriptionRuntimeInfo.MessageCountDetails.DeadLetterMessageCount
                });
            }

            return(result);
        }
Example #4
0
 public SbSender(string NamespaceConnectionString, string EntityPath, SbEntityTypes EntityType, ISbManager sbManager)
 {
     if (sbManager.QueueOrTopicExists(EntityPath, EntityType))
     {
         this.messageSender = new MessageSender(NamespaceConnectionString, EntityPath, null);
         this.messageSender.ServiceBusConnection.TransportType = TransportType.AmqpWebSockets;
     }
     else
     {
         throw new NonExistentEntityException(String.Format("{0} {1} does not exist", EntityType, EntityPath));
     }
 }
Example #5
0
        public SbReceiver(string NamespaceConnectionString, string TopicName, string SubscriptionName, bool ReceiveFromDeadLetter, ISbManager sbManager, bool PurgeMode = false)
        {
            tokenCancel = new CancellationTokenSource();

            ReceiveMode receiveMode = ReceiveMode.PeekLock;

            if (PurgeMode)
            {
                receiveMode = ReceiveMode.ReceiveAndDelete;
            }

            if (sbManager.SubscriptionExists(TopicName, SubscriptionName))
            {
                string subscriptionPath = sbManager.BuildSubscriptionPath(TopicName, SubscriptionName);
                string entityPath       = subscriptionPath;

                if (ReceiveFromDeadLetter)
                {
                    entityPath = sbManager.BuildDeadLetterPath(subscriptionPath);
                }

                this.messageReceiver = CreateMessageReceiver(NamespaceConnectionString, entityPath, receiveMode);
            }
            else
            {
                throw new NonExistentEntityException(String.Format("Subscription {0} does not exist in Topic {1}", SubscriptionName, TopicName));
            }
        }
Example #6
0
        public SbReceiver(string NamespaceConnectionString, string QueueName, bool ReceiveFromDeadLetter, ISbManager sbManager, bool PurgeMode = false)
        {
            tokenCancel = new CancellationTokenSource();

            ReceiveMode receiveMode = ReceiveMode.PeekLock;

            if (PurgeMode)
            {
                receiveMode = ReceiveMode.ReceiveAndDelete;
            }

            if (sbManager.QueueOrTopicExists(QueueName, SbEntityTypes.Queue))
            {
                string entityPath = QueueName;

                if (ReceiveFromDeadLetter)
                {
                    entityPath = sbManager.BuildDeadLetterPath(QueueName);
                }

                this.messageReceiver = CreateMessageReceiver(NamespaceConnectionString, entityPath, receiveMode);
            }
            else
            {
                throw new NonExistentEntityException(String.Format("{0} {1} does not exist", SbEntityTypes.Queue, QueueName));
            }
        }