Skip to content

Commit

Permalink
[Event Hubs] Error handling for disabled entities (#39715)
Browse files Browse the repository at this point in the history
* [Event Hubs] Error handling for disabled entities

The focus of these changes is to add dedicated handling when an Event Hub
resource has been set to "disabled" status.  This is now treated as a terminal
error with a "ResourceNotFound" status, as it requires manual intervention.
Previously, this would result in a general communication error that was
transient and triggered implicit retries.
  • Loading branch information
jsquire authored Nov 2, 2023
1 parent 53c86bc commit 17a12b5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Other Changes

- When an Event Hub is disabled, it will now be detected and result in a terminal `EventHubsException` with its reason set to `FailureReason.ResourceNotFound`.

## 5.9.3 (2023-09-12)

### Other Changes
Expand Down
2 changes: 2 additions & 0 deletions sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Other Changes

- When an Event Hub is disabled, it will now be detected and result in a terminal `EventHubsException` with its reason set to `FailureReason.ResourceNotFound`.

## 5.9.3 (2023-09-12)

### Bugs Fixed
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/Azure.Messaging.EventHubs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The exception includes some contextual information to assist in understanding th

- **Consumer Disconnected** : A consumer client was disconnected by the Event Hub service from the Event Hub instance. This typically occurs when a consumer with a higher owner level asserts ownership over a partition and consumer group pairing.

- **Resource Not Found**: An Event Hubs resource, such as an Event Hub, consumer group, or partition, could not be found by the Event Hubs service. This may indicate that it has been deleted from the service or that there is an issue with the Event Hubs service itself.
- **Resource Not Found**: An Event Hubs resource, such as an Event Hub, consumer group, or partition, could not be found by the Event Hubs service. This may indicate that it has been disabled, is still in the process of being created, was deleted from the service, or that there is an issue with the Event Hubs service itself.

Reacting to a specific failure reason for the [EventHubsException][EventHubsException] can be accomplished in several ways, the most common of which is by applying an exception filter clause as part of the `catch` block:

Expand Down
13 changes: 13 additions & 0 deletions sdk/eventhub/Azure.Messaging.EventHubs/src/Amqp/AmqpError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ internal static class AmqpError
///
public static AmqpSymbol TimeoutError { get; } = AmqpConstants.Vendor + ":timeout";

/// <summary>
/// Indicates that an entity was disabled.
/// </summary>
///
public static AmqpSymbol DisabledError { get; } = AmqpConstants.Vendor + ":entity-disabled";

/// <summary>
/// Indicates that the server was busy and could not allow the requested operation.
/// </summary>
Expand Down Expand Up @@ -171,6 +177,13 @@ private static Exception CreateException(string condition,
return new EventHubsException(eventHubsResource, description, EventHubsException.FailureReason.ServiceTimeout, innerException);
}

// The Event Hubs resource was disabled.

if (string.Equals(condition, DisabledError.Value, StringComparison.InvariantCultureIgnoreCase))
{
return new EventHubsException(eventHubsResource, description, EventHubsException.FailureReason.ResourceNotFound, innerException);
}

// The Event Hubs service was busy; this likely means that requests are being throttled.

if (string.Equals(condition, ServerBusyError.Value, StringComparison.InvariantCultureIgnoreCase))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static IEnumerable<object[]> SimpleConditionExceptionMatchTestCases()
// Custom conditions.

yield return new object[] { AmqpError.TimeoutError, typeof(EventHubsException), EventHubsException.FailureReason.ServiceTimeout };
yield return new object[] { AmqpError.DisabledError, typeof(EventHubsException), EventHubsException.FailureReason.ResourceNotFound };
yield return new object[] { AmqpError.ServerBusyError, typeof(EventHubsException), EventHubsException.FailureReason.ServiceBusy };
yield return new object[] { AmqpError.ProducerStolenError, typeof(EventHubsException), EventHubsException.FailureReason.ProducerDisconnected };
yield return new object[] { AmqpError.SequenceOutOfOrderError, typeof(EventHubsException), EventHubsException.FailureReason.InvalidClientState };
Expand Down

0 comments on commit 17a12b5

Please sign in to comment.