Bhushan Jagtap
Bhushan Jagtap

Reputation: 121

TryTimeout for EventHubProducerClient SendAsync

We can setup timeout value for EventHubProducerClient.SendAsync() while connection creation using EventHubProducerClientOptions.

I have initialized EventHubProducerClientOptions.TryTimeout with 10 seconds and EventHubProducerClientOptions.MaximumRetries to 3.

Does TryTimeout value applicable for each individual retries (10 seconds * 3 retries) or TryTimeout value is shared between all retries?

Example:

If each individual retry takes 5 seconds before failing, then first approach will timeout after 15 seconds verses second approach, which will timeout after 10 seconds with 2 retries.

Upvotes: 0

Views: 470

Answers (1)

Jesse Squire
Jesse Squire

Reputation: 7755

The TryTimeout governs a single service operation. In the case of transient failures with retries, the EventHubsRetryOptions for MaximumDelay, Mode, and (sometimes) Delay control the delay between those attempts.

You'll see the call take MaximumRetries * TryTimeout * retry policy delays. With the default exponential retry pattern, delays contain a small amount of random jitter, so you cannot reasonably predict the exact amount of delay.

To illustrate, let's take your scenario and assume that each service operation times out. The pattern that you would see is:

  • Your application makes a call to SendAsync

  • The service operation times out after 10 seconds (TryTimeout)

  • The failure is deemed transient, the retry policy is consulted and specifies a delay. This is governed by the retry options and will be <= the MaximumDelay value.

  • After the retry delay, the service operation is made a second time and times out after 10 seconds.

  • The failure is deemed transient, the retry policy specifies a delay.

  • After the retry delay, the service operation is made for a third time and times out after 10 seconds.

  • The failure is deemed transient, the retry policy recognizes that it is out of retries (MaximumRetries was set to 3) and does not specify a delay.

  • The call to SendAsync returns control to your application, throwing a TimeoutException.

Upvotes: 1

Related Questions