Don't retry runtime operation if close called on the client. (#313)
* Don't retry if close called on the client. * Encapsulate closeCalled * add this.
This commit is contained in:
Родитель
ba780ef864
Коммит
4fc6c60288
|
@ -87,7 +87,7 @@ namespace Microsoft.Azure.EventHubs.Amqp
|
|||
{
|
||||
// Evaluate retry condition?
|
||||
TimeSpan? retryInterval = this.RetryPolicy.GetNextRetryInterval(ex, timeoutHelper.RemainingTime(), ++retryCount);
|
||||
if (retryInterval != null)
|
||||
if (retryInterval != null && !this.EventHubClient.CloseCalled)
|
||||
{
|
||||
await Task.Delay(retryInterval.Value).ConfigureAwait(false);
|
||||
shouldRetry = true;
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace Microsoft.Azure.EventHubs.Amqp
|
|||
{
|
||||
// Evaluate retry condition?
|
||||
TimeSpan? retryInterval = this.RetryPolicy.GetNextRetryInterval(ex, timeoutHelper.RemainingTime(), ++retryCount);
|
||||
if (retryInterval != null)
|
||||
if (retryInterval != null && !this.EventHubClient.CloseCalled)
|
||||
{
|
||||
await Task.Delay(retryInterval.Value).ConfigureAwait(false);
|
||||
shouldRetry = true;
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Microsoft.Azure.EventHubs
|
|||
public abstract class EventHubClient : ClientEntity
|
||||
{
|
||||
EventDataSender innerSender;
|
||||
bool closeCalled = false;
|
||||
|
||||
internal EventHubClient(EventHubsConnectionStringBuilder csb)
|
||||
: base($"{nameof(EventHubClient)}{ClientEntity.GetNextId()}({csb.EntityPath})")
|
||||
|
@ -241,6 +242,8 @@ namespace Microsoft.Azure.EventHubs
|
|||
/// <returns></returns>
|
||||
public sealed override async Task CloseAsync()
|
||||
{
|
||||
this.closeCalled = true;
|
||||
|
||||
EventHubsEventSource.Log.ClientCloseStart(this.ClientId);
|
||||
try
|
||||
{
|
||||
|
@ -560,6 +563,8 @@ namespace Microsoft.Azure.EventHubs
|
|||
set;
|
||||
}
|
||||
|
||||
internal bool CloseCalled { get => this.closeCalled; }
|
||||
|
||||
internal EventDataSender CreateEventSender(string partitionId = null)
|
||||
{
|
||||
return this.OnCreateEventSender(partitionId);
|
||||
|
|
Загрузка…
Ссылка в новой задаче