Пример #1
0
        async Task DisableWithReceiverOptions()
        {
            // Send single event
            await TestUtility.SendToPartitionAsync(this.EventHubClient, targetPartitionId, "this is the message body");

            // Enable runtime metrics on the client.
            var defaultReceiverRuntimeMetricSetting = this.EventHubClient.EnableReceiverRuntimeMetric;

            this.EventHubClient.EnableReceiverRuntimeMetric = true;

            try
            {
                // Create a new receiver and disable runtime metrics via ReceiverOptions.
                var partitionReceiver =
                    this.EventHubClient.CreateReceiver(PartitionReceiver.DefaultConsumerGroupName, targetPartitionId, EventPosition.FromStart(),
                                                       new ReceiverOptions()
                {
                    EnableReceiverRuntimeMetric = false
                });

                await ValidateDisabledBehavior(partitionReceiver);
            }
            finally
            {
                this.EventHubClient.EnableReceiverRuntimeMetric = defaultReceiverRuntimeMetricSetting;
            }
        }
Пример #2
0
        async Task DefaultBehaviorDisabled()
        {
            // Send single event
            await TestUtility.SendToPartitionAsync(this.EventHubClient, targetPartitionId, "this is the message body");

            // Create a new receiver and validate ReceiverRuntimeMetricEnabled.
            var partitionReceiver = this.EventHubClient.CreateReceiver(PartitionReceiver.DefaultConsumerGroupName, targetPartitionId, EventPosition.FromStart());

            await ValidateDisabledBehavior(partitionReceiver);
        }