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 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); }
private void CreateEventHub(string eventHubName, string consumerGroup) { NamespaceManager ns = NamespaceManager.CreateFromConnectionString(Connections.EventHubConnectionString); EventHubDescription qd; if (!ns.EventHubExists(eventHubName, out qd)) { ns.CreateEventHub(eventHubName); } ConsumerGroupDescription cgd; if (!ns.ConsumerGroupExists(eventHubName, consumerGroup, out cgd)) { ns.CreateConsumerGroup(eventHubName, consumerGroup); } }
public void CreateIfNotExists() { NamespaceManager ns = NamespaceManager.CreateFromConnectionString(connectionString); EventHubDescription qd; if (!ns.EventHubExists(this.eventHubName, out qd)) { ns.CreateTopic(this.eventHubName); } if (null != consumerGroups && consumerGroups.Any()) { Parallel.ForEach(consumerGroups, consumerGroup => { ConsumerGroupDescription sd; if (!ns.ConsumerGroupExists(this.eventHubName, consumerGroup, out sd)) { ns.CreateConsumerGroup(this.eventHubName, consumerGroup); } }); } }