Skip to content

Commit b8a1c9d

Browse files
authored
[Messaging] Client Lifetime Docs (Azure#30061)
The focus of these changes is to add the remarks for client lifetime to the Service Bus clients and tune the verbiage for the Event Hubs versions.
1 parent 5fce211 commit b8a1c9d

File tree

12 files changed

+66
-26
lines changed

12 files changed

+66
-26
lines changed

sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/EventProcessorClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ namespace Azure.Messaging.EventHubs
3232
///
3333
/// <remarks>
3434
/// The <see cref="EventProcessorClient" /> is safe to cache and use for the lifetime of an application, and that is best practice when the application
35-
/// processes events regularly or semi-regularly. The processor holds responsibility for efficient resource management, working to keep resource usage low during
36-
/// periods of inactivity and manage health during periods of higher use. Calling either the <see cref="StopProcessingAsync" /> or <see cref="StopProcessing" />
37-
/// method when processing is complete or as the application is shutting down will ensure that network resources and other unmanaged objects are properly cleaned up.
35+
/// processes events regularly or semi-regularly. The processor is responsible for ensuring efficient network, CPU, and memory use. Calling either
36+
/// <see cref="StopProcessingAsync" /> or <see cref="StopProcessing" /> when processing is complete or as the application is shutting down will ensure
37+
/// that network resources and other unmanaged objects are properly cleaned up.
3838
/// </remarks>
3939
    ///
4040
[SuppressMessage("Usage", "CA1001:Types that own disposable fields should be disposable.", Justification = "Disposal is managed internally as part of the Stop operation.")]

sdk/eventhub/Azure.Messaging.EventHubs/src/Consumer/EventHubConsumerClient.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ namespace Azure.Messaging.EventHubs.Consumer
3333
/// </summary>
3434
///
3535
/// <remarks>
36-
/// The <see cref="EventHubConsumerClient" /> is safe to cache and use for the lifetime of an application, and that is best practice when the application
37-
/// reads events regularly or semi-regularly. The consumer holds responsibility for efficient resource management, working to keep resource usage low during
38-
/// periods of inactivity and manage health during periods of higher use. Calling either the <see cref="CloseAsync" /> or <see cref="DisposeAsync" />
39-
/// method as the application is shutting down will ensure that network resources and other unmanaged objects are properly cleaned up.
36+
/// The <see cref="EventHubConsumerClient" /> is safe to cache and use for the lifetime of an application, which is the best practice when the application
37+
/// reads events regularly or semi-regularly. The consumer is responsible for ensuring efficient network, CPU, and memory use. Calling either
38+
/// <see cref="CloseAsync" /> or <see cref="DisposeAsync" /> as the application is shutting down will ensure that network resources and other
39+
/// unmanaged objects are properly cleaned up.
4040
/// </remarks>
41+
///
4142
[SuppressMessage("Usage", "AZC0007:DO provide a minimal constructor that takes only the parameters required to connect to the service.", Justification = "Event Hubs are AMQP-based services and don't use ClientOptions functionality")]
4243
public class EventHubConsumerClient : IAsyncDisposable
4344
{

sdk/eventhub/Azure.Messaging.EventHubs/src/Primitives/EventProcessor.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ namespace Azure.Messaging.EventHubs.Primitives
3131
/// <typeparam name="TPartition">The context of the partition for which an operation is being performed.</typeparam>
3232
///
3333
/// <remarks>
34-
/// The <see cref="EventProcessor{TPartition}" /> is safe to cache and use for the lifetime of an application, and that is best practice when the application
35-
/// processes events regularly or semi-regularly. The processor holds responsibility for efficient resource management, working to keep resource usage low during
36-
/// periods of inactivity and manage health during periods of higher use. Calling either the <see cref="StopProcessingAsync" /> or <see cref="StopProcessing" />
37-
/// method when processing is complete or as the application is shutting down will ensure that network resources and other unmanaged objects are properly cleaned up.
34+
/// The <see cref="EventProcessor{TPartition}" /> is safe to cache and use for the lifetime of an application, which is the recommended approach.
35+
/// The processor is responsible for ensuring efficient network, CPU, and memory use. Calling either <see cref="StopProcessingAsync" /> or <see cref="StopProcessing" />
36+
/// when all processing is complete or as the application is shutting down will ensure that network resources and other unmanaged objects are properly cleaned up.
3837
/// </remarks>
3938
///
4039
[SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]

sdk/eventhub/Azure.Messaging.EventHubs/src/Primitives/PartitionReceiver.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ namespace Azure.Messaging.EventHubs.Primitives
2525
/// be used for reading and processing events for the majority of scenarios. The partition receiver is
2626
/// intended to enable scenarios with special needs which require more direct control.</para>
2727
///
28-
/// <para>The <see cref="PartitionReceiver" /> is safe to cache and use for the lifetime of an application, and that is best practice when the application
29-
/// reads events regularly or semi-regularly. The receiver holds responsibility for efficient resource management, working to keep resource usage low during
30-
/// periods of inactivity and manage health during periods of higher use. Calling either the <see cref="CloseAsync" /> or <see cref="DisposeAsync" />
31-
/// method as the application is shutting down will ensure that network resources and other unmanaged objects are properly cleaned up.</para>
28+
/// <para>The <see cref="PartitionReceiver" /> is safe to cache and use for the lifetime of an application, and which is the best practice when the application
29+
/// reads events regularly or semi-regularly. The receiver is responsible for ensuring efficient network, CPU, and memory use. Calling either
30+
/// <see cref="CloseAsync" /> or <see cref="DisposeAsync" /> as the application is shutting down will ensure that network resources and other unmanaged
31+
/// objects are properly cleaned up.</para>
3232
/// </remarks>
3333
///
3434
/// <seealso href="https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor">Azure.Messaging.EventHubs.Processor (NuGet)</seealso>

sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubBufferedProducerClient.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ namespace Azure.Messaging.EventHubs.Producer
4646
///
4747
/// <remarks>
4848
/// The <see cref="EventHubBufferedProducerClient"/> is safe to cache and use as a singleton for the lifetime of an
49-
/// application. This is the recommended approach, since the client is responsible for efficient network,
50-
/// CPU, and memory use. Calling <see cref="CloseAsync(bool, CancellationToken)"/> or <see cref="DisposeAsync"/>
51-
/// is required so that resources can be cleaned up after use.
49+
/// application, which is the recommended approach. The producer is responsible for ensuring efficient network,
50+
/// CPU, and memory use. Calling either <see cref="CloseAsync(bool, CancellationToken)"/> or <see cref="DisposeAsync"/>
51+
/// when no more events will be enqueued or as the application is shutting down is required so that the buffer can be flushed
52+
/// and resources cleaned up properly.
5253
/// </remarks>
5354
///
5455
/// <seealso cref="EventHubProducerClient" />

sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClient.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ namespace Azure.Messaging.EventHubs.Producer
4848
/// </list>
4949
///
5050
/// <para>
51-
/// The <see cref="EventHubProducerClient" /> is safe to cache and use for the lifetime of an application, and that is best practice when the application
52-
/// publishes events regularly or semi-regularly. The producer holds responsibility for efficient resource management, working to keep resource usage low during
53-
/// periods of inactivity and manage health during periods of higher use. Calling either the <see cref="CloseAsync" /> or <see cref="DisposeAsync" />
54-
/// method as the application is shutting down will ensure that network resources and other unmanaged objects are properly cleaned up.
51+
/// The <see cref="EventHubProducerClient" /> is safe to cache and use for the lifetime of an application, which is the best practice when the application
52+
/// publishes events regularly or semi-regularly. The producer is responsible for ensuring efficient network, CPU, and memory use. Calling either
53+
/// <see cref="CloseAsync" /> or <see cref="DisposeAsync" /> as the application is shutting down will ensure that network resources and other unmanaged objects are properly cleaned up.
5554
/// </para>
5655
/// </remarks>
5756
///

sdk/servicebus/Azure.Messaging.ServiceBus/src/Client/ServiceBusClient.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ namespace Azure.Messaging.ServiceBus
1717
/// same AMQP connection. Disposing the <see cref="ServiceBusClient"/> will cause the AMQP
1818
/// connection to close.
1919
/// </summary>
20+
/// <remarks>
21+
/// The <see cref="ServiceBusClient" /> is safe to cache and use for the lifetime of an
22+
/// application, which is the best practice when the application is making use of Service Bus
23+
/// regularly or semi-regularly. The client is responsible for ensuring efficient network, CPU,
24+
/// and memory use. Calling <see cref="DisposeAsync" /> as the application is shutting down
25+
/// will ensure that network resources and other unmanaged objects are properly cleaned up.
26+
///</remarks>
2027
public class ServiceBusClient : IAsyncDisposable
2128
{
2229
private readonly ServiceBusClientOptions _options;

sdk/servicebus/Azure.Messaging.ServiceBus/src/Processor/ServiceBusProcessor.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ namespace Azure.Messaging.ServiceBus
2323
/// property. The error handler is specified with the <see cref="ProcessErrorAsync"/> property.
2424
/// To start processing after the handlers have been specified, call <see cref="StartProcessingAsync"/>.
2525
/// </summary>
26+
/// <remarks>
27+
/// The <see cref="ServiceBusProcessor" /> is safe to cache and use for the lifetime of an application
28+
/// or until the <see cref="ServiceBusClient" /> that it was created by is disposed. Caching the processor
29+
/// is recommended when the application is processing messages regularly. The sender is responsible for
30+
/// ensuring efficient network, CPU, and memory use. Calling <see cref="DisposeAsync" /> on the
31+
/// associated <see cref="ServiceBusClient" /> as the application is shutting down will ensure that
32+
/// network resources and other unmanaged objects used by the processor are properly cleaned up.
33+
/// </remarks>
2634
#pragma warning disable CA1001 // Types that own disposable fields should be disposable
2735
public class ServiceBusProcessor : IAsyncDisposable
2836
#pragma warning restore CA1001 // Types that own disposable fields should be disposable
@@ -1117,4 +1125,4 @@ private async Task ReconcileConcurrencyAsync()
11171125
_currentConcurrentSessions = maxConcurrentSessions;
11181126
}
11191127
}
1120-
}
1128+
}

sdk/servicebus/Azure.Messaging.ServiceBus/src/Processor/ServiceBusSessionProcessor.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ namespace Azure.Messaging.ServiceBus
1818
/// property. The error handler is specified with the <see cref="ProcessErrorAsync"/> property.
1919
/// To start processing after the handlers have been specified, call <see cref="StartProcessingAsync"/>.
2020
/// </summary>
21+
/// <remarks>
22+
/// The <see cref="ServiceBusSessionProcessor" /> is safe to cache and use for the lifetime of an application
23+
/// or until the <see cref="ServiceBusClient" /> that it was created by is disposed. Caching the processor
24+
/// is recommended when the application is processing messages regularly. The sender is responsible for
25+
/// ensuring efficient network, CPU, and memory use. Calling <see cref="DisposeAsync" /> on the
26+
/// associated <see cref="ServiceBusClient" /> as the application is shutting down will ensure that
27+
/// network resources and other unmanaged objects used by the processor are properly cleaned up.
28+
/// </remarks>
2129
public class ServiceBusSessionProcessor : IAsyncDisposable
2230
{
2331
/// <summary>
@@ -331,4 +339,4 @@ public void UpdateConcurrency(int maxConcurrentSessions, int maxConcurrentCallsP
331339
InnerProcessor.UpdateConcurrency(maxConcurrentSessions, maxConcurrentCallsPerSession);
332340
}
333341
}
334-
}
342+
}

sdk/servicebus/Azure.Messaging.ServiceBus/src/Receiver/ServiceBusReceiver.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ namespace Azure.Messaging.ServiceBus
2222
/// <see cref="ServiceBusReceivedMessage" /> and settling messages from Queues and Subscriptions.
2323
/// It is constructed by calling <see cref="ServiceBusClient.CreateReceiver(string, ServiceBusReceiverOptions)"/>.
2424
/// </summary>
25+
/// <remarks>
26+
/// The <see cref="ServiceBusReceiver" /> is safe to cache and use for the lifetime of an
27+
/// application or until the <see cref="ServiceBusClient" /> that it was created by is disposed.
28+
/// Caching the receiver is recommended when the application is consuming messages
29+
/// regularly or semi-regularly. The receiver is responsible for ensuring efficient network, CPU,
30+
/// and memory use. Calling <see cref="DisposeAsync" /> on the associated <see cref="ServiceBusClient" />
31+
/// as the application is shutting down will ensure that network resources and other unmanaged objects used
32+
/// by the receiver are properly cleaned up.
33+
///</remarks>
2534
public class ServiceBusReceiver : IAsyncDisposable
2635
{
2736
/// <summary>
@@ -1197,4 +1206,4 @@ public virtual async ValueTask DisposeAsync()
11971206
[EditorBrowsable(EditorBrowsableState.Never)]
11981207
public override string ToString() => base.ToString();
11991208
}
1200-
}
1209+
}

0 commit comments

Comments
 (0)