コード例 #1
0
        public void TestConsumerGroup()
        {
            string              name = "testConsumerGroupEventHub";
            string              consumerGroupName = "consumergroup1";
            NamespaceManager    ns          = NamespaceManager.CreateFromConnectionString(eventHubConnectionString);
            EventHubDescription description = ns.CreateEventHub(name);

            Assert.IsTrue(null != description);
            ConsumerGroupDescription cgDescription = ns.CreateConsumerGroup(name, consumerGroupName);

            if (!ns.ConsumerGroupExists(name, consumerGroupName, out cgDescription))
            {
                Assert.Fail("Consumer Group did not exist");
            }
            else
            {
                Assert.IsTrue(null != cgDescription);
                ns.DeleteConsumerGroup(name, consumerGroupName);
                if (ns.ConsumerGroupExists(name, consumerGroupName, out cgDescription))
                {
                    Assert.Fail("Consumer Group was not deleted");
                }

                ns.DeleteEventHub(name);
                if (ns.EventHubExists(name, out description))
                {
                    Assert.Fail("EventHub was not deleted");
                }
            }
        }
        public void DeleteEventHubs(Property[] inputs, RequiredProperties required, Property[] returns, MethodType methodType, ServiceObject serviceObject)
        {
            Utilities.ServiceUtilities serviceUtilities = new Utilities.ServiceUtilities(serviceBroker);
            serviceObject.Properties.InitResultTable();
            NamespaceManager namespaceManager = null;

            try
            {
                string eventhubpath = string.Empty;
                if (inputs.Length == 0)
                {
                    eventhubpath = serviceObject.MetaData.DisplayName;
                }
                else
                {
                    eventhubpath = inputs.Where(p => p.Name.Equals("eventhub")).First().Value.ToString();
                }

                namespaceManager = serviceUtilities.GetNamespaceManager(inputs.Where(p => p.Name.Equals("requesttimeout")).FirstOrDefault());
                namespaceManager.DeleteEventHub(eventhubpath);
                returns.Where(p => p.Name.Equals("responsestatus")).First().Value            = ResponseStatus.Success;
                returns.Where(p => p.Name.Equals("responsestatusdescription")).First().Value = "Event Hub deleted";
            }
            catch (Exception ex)
            {
                returns.Where(p => p.Name.Equals("responsestatus")).First().Value            = ResponseStatus.Error;
                returns.Where(p => p.Name.Equals("responsestatusdescription")).First().Value = ex.Message;
            }
            finally
            {
                namespaceManager = null;
            }

            serviceObject.Properties.BindPropertiesToResultTable();
        }
コード例 #3
0
        private void DeleteEventHub(string eventHubName)
        {
            recieving = false;
            cts.Cancel();
            NamespaceManager    ns = NamespaceManager.CreateFromConnectionString(Connections.EventHubConnectionString);
            EventHubDescription qd;

            if (ns.EventHubExists(eventHubName, out qd))
            {
                Console.WriteLine("Deleting Event Hub" + eventHubName);
                ns.DeleteEventHub(eventHubName);
            }
        }
コード例 #4
0
        public void TestParition()
        {
            string              name = "testpartitionEventHub";
            string              consumerGroupName = "consumergroup1";
            NamespaceManager    ns          = NamespaceManager.CreateFromConnectionString(eventHubConnectionString);
            EventHubDescription description = ns.CreateEventHub(name);

            Assert.IsTrue(null != description);
            ConsumerGroupDescription cgDescription = ns.CreateConsumerGroup(name, consumerGroupName);
            PartitionDescription     pd            = ns.GetEventHubPartition(name, consumerGroupName, "1");

            Assert.IsTrue(null != pd);

            ns.DeleteEventHub(name);
        }
コード例 #5
0
        public void TestEventHub()
        {
            string              name        = "testEventHub";
            NamespaceManager    ns          = NamespaceManager.CreateFromConnectionString(eventHubConnectionString);
            EventHubDescription description = ns.CreateEventHub("testEventHub");

            Assert.IsTrue(null != description);

            if (!ns.EventHubExists(name, out description))
            {
                Assert.Fail("EventHub did not exist");
            }
            else
            {
                Assert.IsTrue(null != description);
                ns.DeleteEventHub(name);
                if (ns.EventHubExists(name, out description))
                {
                    Assert.Fail("EventHub was not deleted");
                }
            }
        }