コード例 #1
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);
        }
コード例 #2
0
        static void MonitorClients(object obj)
        {
            if (monitorLock.IsSet)
            {
                // There is one already running.
                return;
            }

            monitorLock.Set();
            int totalSent = 0;

            // Log total number of events sent from each client.
            Console.WriteLine("\nEvent Count Metrics:");
            Console.WriteLine("====================");
            senderClients.ForEach(sc =>
            {
                var thisSent = sc.totalNumberOfEventsSent;
                Console.WriteLine("Client-{0}: {1} events sent", sc.ClientInd, thisSent);
                totalSent += thisSent;
            });

            Console.WriteLine("Total Sent: {0}", totalSent);

            // Log partition metrics which will tell us how fast we're sending.
            try
            {
                Console.WriteLine("\nIncoming Throughput Metrics:");
                Console.WriteLine("=============================");
                for (int partitionId = 0; partitionId < PartitionCount; partitionId++)
                {
                    var partition = nm.GetEventHubPartition(EhName, EventHubConsumerGroup.DefaultGroupName, partitionId.ToString());
                    Console.WriteLine("Partition {0}: {1} KBytes/sec", partitionId, Math.Round((double)partition.IncomingBytesPerSecond / 1024, 1));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Caught exception while getting partition throughput metrics: {1}", ex.Message);
            }

            monitorLock.Reset();
        }