Esempio n. 1
0
        public QueueClient Create(Address address)
        {
            var queueName = address.Queue;

            try
            {
                if (!NamespaceClient.QueueExists(queueName))
                {
                    var description = new QueueDescription(queueName)
                    {
                        LockDuration                           = LockDuration,
                        MaxSizeInMegabytes                     = MaxSizeInMegabytes,
                        RequiresDuplicateDetection             = RequiresDuplicateDetection,
                        RequiresSession                        = RequiresSession,
                        DefaultMessageTimeToLive               = DefaultMessageTimeToLive,
                        EnableDeadLetteringOnMessageExpiration = EnableDeadLetteringOnMessageExpiration,
                        DuplicateDetectionHistoryTimeWindow    = DuplicateDetectionHistoryTimeWindow,
                        MaxDeliveryCount                       = MaxDeliveryCount,
                        EnableBatchedOperations                = EnableBatchedOperations
                    };

                    NamespaceClient.CreateQueue(description);
                }
            }
            catch (MessagingEntityAlreadyExistsException)
            {
                // the queue already exists or another node beat us to it, which is ok
            }

            var client = Factory.CreateQueueClient(queueName, ReceiveMode.PeekLock);

            client.PrefetchCount = 100; // todo make configurable
            return(client);
        }
Esempio n. 2
0
 private GitLabClient(string hostUrl, string apiToken)
 {
     _api     = new API(hostUrl, apiToken);
     Users    = new UserClient(_api);
     Projects = new ProjectClient(_api);
     Issues   = new IssueClient(_api);
     Groups   = new NamespaceClient(_api);
 }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eventType"></param>
        /// <param name="original"></param>
        public void Unsubscribe(Type eventType, Address original)
        {
            var publisherAddress = Address.Parse(AzureServiceBusPublisherAddressConvention.Create(original));
            var subscriptionname = AzureServiceBusSubscriptionNameConvention.Create(eventType);

            if (NamespaceClient.SubscriptionExists(publisherAddress.Queue, subscriptionname))
            {
                NamespaceClient.DeleteSubscription(publisherAddress.Queue, subscriptionname);
            }

            // unhook the listener
        }
        public SubscriptionClient Create(Type eventType, string topicPath, string subscriptionname)
        {
            if (NamespaceClient.TopicExists(topicPath))
            {
                try
                {
                    if (!NamespaceClient.SubscriptionExists(topicPath, subscriptionname))
                    {
                        var description = new SubscriptionDescription(topicPath, subscriptionname)
                        {
                            LockDuration             = LockDuration,
                            RequiresSession          = RequiresSession,
                            DefaultMessageTimeToLive = DefaultMessageTimeToLive,
                            EnableDeadLetteringOnMessageExpiration = EnableDeadLetteringOnMessageExpiration,
                            MaxDeliveryCount        = MaxDeliveryCount,
                            EnableBatchedOperations = EnableBatchedOperations,
                            EnableDeadLetteringOnFilterEvaluationExceptions =
                                EnableDeadLetteringOnFilterEvaluationExceptions
                        };

                        if (eventType != null)
                        {
                            var filter =
                                string.Format(
                                    "[{0}] LIKE '{1}%' OR [{0}] LIKE '%{1}%' OR [{0}] LIKE '%{1}' OR [{0}] = '{1}'",
                                    Headers.EnclosedMessageTypes, eventType.AssemblyQualifiedName);
                            var typefilter = new SqlFilter(filter);

                            NamespaceClient.CreateSubscription(description, typefilter);
                        }
                        else
                        {
                            NamespaceClient.CreateSubscription(description);
                        }
                    }
                }
                catch (MessagingEntityAlreadyExistsException)
                {
                    // the queue already exists or another node beat us to it, which is ok
                }

                return(Factory.CreateSubscriptionClient(topicPath, subscriptionname, ReceiveMode.PeekLock));
            }
            return(null);
        }