예제 #1
0
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Usage: BeeHive.Azure.Pusher <azure service bus namespace> <topic name> <file name>");
                return;
            }

            try
            {
                var serviceBusOperator = new ServiceBusOperator(args[0]);
                serviceBusOperator.PushAsync(new Event()
                {
                    Body        = File.ReadAllText(args[2]),
                    ContentType = "application/json",
                    EventType   = "Standard",
                    QueueName   = QueueName.FromTopicName(args[1]).ToString(),
                    Timestamp   = DateTimeOffset.Now
                }).Wait();

                Console.WriteLine("Message was sent successfully");
            }
            catch (Exception e)
            {
                Console.WriteLine("DAILED: " + e.ToString());
            }
        }
예제 #2
0
        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();
        }
예제 #3
0
파일: Program.cs 프로젝트: csuffyy/BeeHive
        static void Main(string[] args)
        {

            if (args.Length != 3)
            {
                Console.WriteLine("Usage: BeeHive.Azure.Pusher <azure service bus namespace> <topic name> <file name>");
                return;
            }

            try
            {
                var serviceBusOperator = new ServiceBusOperator(args[0]);
                serviceBusOperator.PushAsync(new Event()
                {
                    Body = File.ReadAllText(args[2]),
                    ContentType = "application/json",
                    EventType = "Standard",
                    QueueName = QueueName.FromTopicName(args[1]).ToString(),
                    Timestamp = DateTimeOffset.Now
                }).Wait();

                Console.WriteLine("Message was sent successfully");
            }
            catch (Exception e)
            {                
                Console.WriteLine("DAILED: " + e.ToString());
            }
        }
예제 #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();
        }
예제 #5
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();


        }
예제 #6
0
        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();


        }