Esempio n. 1
0
        public virtual QueueClient QueueDeclare(string name, bool autoDelete = false)
        {
            Preconditions.CheckNotNull(name, "name");

            return(this.queues.GetOrAdd(
                       name,
                       s =>
            {
#if DEBUG
                SslValidator.OverrideValidation();
#endif
                if (!namespaceManager.QueueExists(s))
                {
                    var description = new QueueDescription(s);
                    if (autoDelete)
                    {
                        description.AutoDeleteOnIdle = TimeSpan.FromMinutes(5);
                    }

                    description.DefaultMessageTimeToLive = TimeSpan.FromDays(5);
                    description.EnableDeadLetteringOnMessageExpiration = true;
                    description.LockDuration = TimeSpan.FromSeconds(15);

                    logger.DebugWrite("Declared Queue: '{0}'", name);
                    namespaceManager.CreateQueue(description);
                }

                var client = messagingFactory.CreateQueueClient(s);
                client.PrefetchCount = configuration.PrefetchCount;

                return client;
            }));
        }
Esempio n. 2
0
        public TopicClient TopicDeclare(string name, bool requiresDuplicateDetection)
        {
            var topicClient = this.topics.GetOrAdd(
                name,
                n =>
            {
#if DEBUG
                SslValidator.OverrideValidation();
#endif
                if (!this.namespaceManager.TopicExists(n))
                {
                    var description = new TopicDescription(n)
                    {
                        RequiresDuplicateDetection = requiresDuplicateDetection
                    };

                    this.logger.DebugWrite("Declared Topic: '{0}'", n);
                    this.namespaceManager.CreateTopic(description);
                }

                var client = this.messagingFactory.CreateTopicClient(n);
                return(client);
            });

            return(topicClient);
        }
Esempio n. 3
0
        public TopicClient TopicFind(string name)
        {
            var topicClient = this.topics.GetOrAdd(
                name,
                n =>
            {
#if DEBUG
                SslValidator.OverrideValidation();
#endif
                return(this.namespaceManager.TopicExists(n) ? this.messagingFactory.CreateTopicClient(n) : null);
            });

            return(topicClient);
        }
Esempio n. 4
0
        public void TopicDelete(string topic)
        {
            TopicClient toRemove;

            if (this.topics.TryRemove(topic, out toRemove))
            {
#if DEBUG
                SslValidator.OverrideValidation();
#endif
                if (this.namespaceManager.TopicExists(topic))
                {
                    this.namespaceManager.DeleteTopic(topic);
                }
            }
        }
Esempio n. 5
0
        public void QueueDelete(string name)
        {
            QueueClient toRemove;

            if (this.queues.TryRemove(name, out toRemove))
            {
#if DEBUG
                SslValidator.OverrideValidation();
#endif
                if (this.namespaceManager.QueueExists(name))
                {
                    this.namespaceManager.DeleteQueue(name);
                }
            }
        }
 public SimpleWebSource(string feedUrl)
 {
     FeedUrl = feedUrl;
     Proxy   = null;
     SslValidator.OverrideValidation(); //download from https, even if there are no certs in mono/windows store
 }
Esempio n. 7
0
        public SubscriptionClient SubscriptionDeclare(
            string name,
            List <string> topicNames,
            string subscription,
            ReceiveMode receiveMode,
            bool requiresDuplicateDetection,
            int maxDeliveryCount)
        {
            var topicClient = this.TopicDeclare(name, requiresDuplicateDetection);

            return(this.subscriptions.GetOrAdd(
                       BuildSubscriptionKey(name, subscription, topicNames),
                       s =>
            {
#if DEBUG
                SslValidator.OverrideValidation();
#endif
                var parts = new List <string> {
                    subscription
                };
                parts.AddRange(topicNames);

                var subscriptionId =
                    string.Join("-", parts.Where(o => !string.IsNullOrEmpty(o)))
                    .Replace("#", "_")
                    .Replace("*", "_");

                if (!namespaceManager.SubscriptionExists(topicClient.Path, subscriptionId))
                {
                    var description = new SubscriptionDescription(topicClient.Path, subscriptionId)
                    {
                        MaxDeliveryCount = maxDeliveryCount,
                        DefaultMessageTimeToLive = TimeSpan.FromDays(5),
                        EnableDeadLetteringOnMessageExpiration = true,
                        LockDuration = TimeSpan.FromMinutes(1)
                    };

                    if (topicNames.Any())
                    {
                        var expression = string.Join(
                            " OR ",
                            topicNames.Select(
                                o => string.Format("user.topic LIKE '{0}'", TransformWildcards(o))));

                        var filter = new SqlFilter(expression);
                        namespaceManager.CreateSubscription(description, filter);

                        logger.DebugWrite(
                            "Declared Subscription: '{0}' on Topic {1} with filter {2}",
                            subscription,
                            topicClient.Path,
                            filter);
                    }
                    else
                    {
                        namespaceManager.CreateSubscription(description);
                        logger.DebugWrite(
                            "Declared Subscription: '{0}' on Topic {1}",
                            subscription,
                            topicClient.Path);
                    }
                }

                return messagingFactory.CreateSubscriptionClient(topicClient.Path, subscriptionId, receiveMode);
            }));
        }