diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClient.cs b/sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClient.cs index ab9d9447bd70..d1084f68f460 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClient.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClient.cs @@ -491,64 +491,6 @@ internal virtual async Task GetPartitionPublishin } } - /// - /// Sends the to the associated Event Hub. To avoid the - /// overhead associated with measuring and validating the size in the client, validation will - /// be delegated to the Event Hubs service and is deferred until the operation is invoked. - /// The call will fail if the size of the specified exceeds the - /// maximum allowable size of a single event. - /// - /// - /// The event data to send. - /// An optional instance to signal the request to cancel the operation. - /// - /// - /// A task to be resolved on when the operation has completed; if no exception is thrown when awaited, the - /// Event Hubs service has acknowledge receipt and assumed responsibility for delivery of the event. - /// - /// - /// - /// - /// - /// - /// - internal virtual async Task SendAsync(EventData eventData, - CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(eventData, nameof(eventData)); - await SendAsync(new[] { eventData }, null, cancellationToken).ConfigureAwait(false); - } - - /// - /// Sends the to the associated Event Hub. To avoid the - /// overhead associated with measuring and validating the size in the client, validation will - /// be delegated to the Event Hubs service and is deferred until the operation is invoked. - /// The call will fail if the size of the specified exceeds the - /// maximum allowable size of a single event. - /// - /// - /// The event data to send. - /// The set of options to consider when sending this batch. - /// An optional instance to signal the request to cancel the operation. - /// - /// - /// A task to be resolved on when the operation has completed; if no exception is thrown when awaited, the - /// Event Hubs service has acknowledge receipt and assumed responsibility for delivery of the event. - /// - /// - /// - /// - /// - /// - /// - internal virtual async Task SendAsync(EventData eventData, - SendEventOptions options, - CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(eventData, nameof(eventData)); - await SendAsync(new[] { eventData }, options, cancellationToken).ConfigureAwait(false); - } - /// /// Sends a set of events to the associated Event Hub as a single operation. To avoid the /// overhead associated with measuring and validating the size in the client, validation will diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Diagnostics/DiagnosticsTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Diagnostics/DiagnosticsTests.cs index 533c5ea92fbf..3b112d4efd4c 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Diagnostics/DiagnosticsTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Diagnostics/DiagnosticsTests.cs @@ -59,7 +59,7 @@ public async Task EventHubProducerCreatesDiagnosticScopeOnSend() var producer = new EventHubProducerClient(fakeConnection, transportMock.Object); var eventData = new EventData(ReadOnlyMemory.Empty); - await producer.SendAsync(eventData); + await producer.SendAsync(new[] { eventData }); activity.Stop(); diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Producer/EventHubProducerClientLiveTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Producer/EventHubProducerClientLiveTests.cs index b5c2c651f598..8d08898ec3f7 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Producer/EventHubProducerClientLiveTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Producer/EventHubProducerClientLiveTests.cs @@ -229,48 +229,6 @@ public async Task ProducerCanSendAnEventBatchUsingAPartitionHashKey() } } - /// - /// Verifies that the is able to - /// connect to the Event Hubs service and perform operations. - /// - /// - [Test] - public async Task ProducerCanSendSingleZeroLengthEvent() - { - await using (EventHubScope scope = await EventHubScope.CreateAsync(1)) - { - var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName); - - await using (var producer = new EventHubProducerClient(connectionString)) - { - var singleEvent = new EventData(Array.Empty()); - Assert.That(async () => await producer.SendAsync(singleEvent), Throws.Nothing); - } - } - } - - /// - /// Verifies that the is able to - /// connect to the Event Hubs service and perform operations. - /// - /// - [Test] - public async Task ProducerCanSendSingleLargeEvent() - { - await using (EventHubScope scope = await EventHubScope.CreateAsync(1)) - { - var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName); - - await using (var producer = new EventHubProducerClient(connectionString, new EventHubProducerClientOptions { RetryOptions = new EventHubsRetryOptions { TryTimeout = TimeSpan.FromMinutes(5) } })) - { - // Actual limit is 1046520 for a single event. - - var singleEvent = new EventData(new byte[100000]); - Assert.That(async () => await producer.SendAsync(singleEvent), Throws.Nothing); - } - } - } - /// /// Verifies that the is able to /// connect to the Event Hubs service and perform operations. @@ -293,31 +251,6 @@ public async Task ProducerCanSendSingleLargeEventInASet() } } - /// - /// Verifies that the is able to - /// connect to the Event Hubs service and perform operations. - /// - /// - [Test] - public async Task ProducerCannotSendSingleEventLargerThanMaximumSize() - { - await using (EventHubScope scope = await EventHubScope.CreateAsync(1)) - { - var connectionString = EventHubsTestEnvironment.Instance.BuildConnectionStringForEventHub(scope.EventHubName); - - await using (var producer = new EventHubProducerClient(connectionString)) - { - // Actual limit is 1046520 for a single event. - - var singleEvent = new EventData(new byte[1500000]); - EventData[] eventBatch = new[] { new EventData(new byte[1500000]) }; - - Assert.That(async () => await producer.SendAsync(singleEvent), Throws.InstanceOf().And.Property(nameof(EventHubsException.Reason)).EqualTo(EventHubsException.FailureReason.MessageSizeExceeded)); - Assert.That(async () => await producer.SendAsync(eventBatch), Throws.InstanceOf().And.Property(nameof(EventHubsException.Reason)).EqualTo(EventHubsException.FailureReason.MessageSizeExceeded)); - } - } - } - /// /// Verifies that the is able to /// connect to the Event Hubs service and perform operations. @@ -1011,7 +944,7 @@ public async Task ProducerSendsEventsWithTheSamePartitionHashKeyToTheSamePartiti for (var index = 0; index < batches; index++) { - await producer.SendAsync(new EventData(Encoding.UTF8.GetBytes($"Just a few messages ({ index })")), batchOptions); + await producer.SendAsync(new[] { new EventData(Encoding.UTF8.GetBytes($"Just a few messages ({ index })")) }, batchOptions); } // Read the events. @@ -1076,7 +1009,7 @@ public async Task ProducerCannotSendWhenProxyIsInvalid() await using (var invalidProxyProducer = new EventHubProducerClient(connectionString, producerOptions)) { - Assert.That(async () => await invalidProxyProducer.SendAsync(new EventData(new byte[1])), Throws.InstanceOf().Or.InstanceOf()); + Assert.That(async () => await invalidProxyProducer.SendAsync(new[] { new EventData(new byte[1]) }), Throws.InstanceOf().Or.InstanceOf()); } } } diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Producer/EventHubProducerClientTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Producer/EventHubProducerClientTests.cs index ed54bea17ca0..e62fa465ea03 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs/tests/Producer/EventHubProducerClientTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs/tests/Producer/EventHubProducerClientTests.cs @@ -514,68 +514,6 @@ public async Task ReadPartitionPublishingPropertiesAsyncReturnsEmptyPartitionSta "Partition state should not have been initialized."); } - /// - /// Verifies functionality of the - /// method. - /// - /// - [Test] - public void SendSingleWithoutOptionsRequiresAnEvent() - { - var producer = new EventHubProducerClient(new MockConnection()); - Assert.That(async () => await producer.SendAsync(default(EventData)), Throws.ArgumentNullException); - } - - /// - /// Verifies functionality of the - /// method. - /// - /// - [Test] - public void SendSingleRequiresAnEvent() - { - var producer = new EventHubProducerClient(new MockConnection()); - Assert.That(async () => await producer.SendAsync(default(EventData), new SendEventOptions()), Throws.ArgumentNullException); - } - - /// - /// Verifies functionality of the - /// method. - /// - /// - [Test] - public async Task SendSingleWithoutOptionsDelegatesToBatchSend() - { - var transportProducer = new ObservableTransportProducerMock(); - var producer = new Mock { CallBase = true }; - - producer - .Setup(instance => instance.SendAsync(It.Is>(value => value.Count() == 1), It.IsAny(), It.IsAny())) - .Returns(Task.CompletedTask) - .Verifiable("The single send should delegate to the batch send."); - - await producer.Object.SendAsync(new EventData(new byte[] { 0x22 })); - } - - /// - /// Verifies functionality of the - /// method. - /// - /// - [Test] - public async Task SendSingleWitOptionsDelegatesToBatchSend() - { - var transportProducer = new ObservableTransportProducerMock(); - var producer = new Mock { CallBase = true }; - - producer - .Setup(instance => instance.SendAsync(It.Is>(value => value.Count() == 1), It.IsAny(), It.IsAny())) - .Returns(Task.CompletedTask) - .Verifiable("The single send should delegate to the batch send."); - - await producer.Object.SendAsync(new EventData(new byte[] { 0x22 }), new SendEventOptions()); - } - /// /// Verifies functionality of the /// method.