public void TopicAndSubscriptionCreateAndSentAndReceivedForOneMinute()
        {
            var topicName          = Guid.NewGuid().ToString("N");
            var subName            = Guid.NewGuid().ToString("N");
            var topicQueueName     = QueueName.FromTopicName(topicName);
            var queueName          = QueueName.FromTopicAndSubscriptionName(topicName, subName);
            var serviceBusOperator = new ServiceBusOperator(ConnectionString);


            serviceBusOperator.CreateQueueAsync(topicQueueName).Wait();
            serviceBusOperator.CreateQueueAsync(queueName).Wait();

            serviceBusOperator.PushAsync(new Event("chashm")
            {
                QueueName = topicQueueName.ToString()
            }).Wait();

            var pollerResult            = serviceBusOperator.NextAsync(queueName).Result;
            var cancellationTokenSource = new CancellationTokenSource();

            serviceBusOperator.KeepExtendingLeaseAsync(pollerResult.PollingResult, TimeSpan.FromSeconds(10),
                                                       cancellationTokenSource.Token);

            Thread.Sleep(35000);
            cancellationTokenSource.Cancel();
            serviceBusOperator.CommitAsync(pollerResult.PollingResult);

            serviceBusOperator.DeleteQueueAsync(queueName).Wait();
            serviceBusOperator.DeleteQueueAsync(topicQueueName).Wait();
        }
示例#2
0
        public async Task TopicAndSubscriptionCreateAndSentBatch()
        {
            var topicName          = Guid.NewGuid().ToString("N");
            var subName            = Guid.NewGuid().ToString("N");
            var topicQueueName     = QueueName.FromTopicName(topicName);
            var queueName          = QueueName.FromTopicAndSubscriptionName(topicName, subName);
            var serviceBusOperator = new ServiceBusOperator(ConnectionString);


            await serviceBusOperator.CreateQueueAsync(topicQueueName);

            await serviceBusOperator.CreateQueueAsync(queueName);

            await serviceBusOperator.PushBatchAsync(new[] { new Event("chashm")
                                                            {
                                                                QueueName = topicQueueName.ToString()
                                                            },
                                                            new Event("chashm")
                                                            {
                                                                QueueName = topicQueueName.ToString()
                                                            } });

            await serviceBusOperator.DeleteQueueAsync(queueName);

            await serviceBusOperator.DeleteQueueAsync(topicQueueName);
        }
示例#3
0
        public void TopicAndSubscriptionCreateAndExists()
        {
            var topicName          = Guid.NewGuid().ToString("N");
            var subName            = Guid.NewGuid().ToString("N");
            var topicQueueName     = QueueName.FromTopicName(topicName);
            var queueName          = QueueName.FromTopicAndSubscriptionName(topicName, subName);
            var serviceBusOperator = new ServiceBusOperator(ConnectionString);


            Assert.False(serviceBusOperator.QueueExistsAsync(queueName).Result);

            serviceBusOperator.CreateQueueAsync(topicQueueName).Wait();
            serviceBusOperator.CreateQueueAsync(queueName).Wait();
            Assert.True(serviceBusOperator.QueueExistsAsync(queueName).Result);

            serviceBusOperator.DeleteQueueAsync(queueName).Wait();
            serviceBusOperator.DeleteQueueAsync(topicQueueName).Wait();
            Assert.False(serviceBusOperator.QueueExistsAsync(queueName).Result);
        }
示例#4
0
        public void TopicAndSubscriptionCreateAndSent()
        {
            var topicName          = Guid.NewGuid().ToString("N");
            var subName            = Guid.NewGuid().ToString("N");
            var topicQueueName     = QueueName.FromTopicName(topicName);
            var queueName          = QueueName.FromTopicAndSubscriptionName(topicName, subName);
            var serviceBusOperator = new ServiceBusOperator(ConnectionString);


            serviceBusOperator.CreateQueueAsync(topicQueueName).Wait();
            serviceBusOperator.CreateQueueAsync(queueName).Wait();

            serviceBusOperator.PushAsync(new Event("chashm")
            {
                QueueName = topicQueueName.ToString()
            }).Wait();

            serviceBusOperator.DeleteQueueAsync(queueName).Wait();
            serviceBusOperator.DeleteQueueAsync(topicQueueName).Wait();
        }