-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[ServiceBus] Improve AMQP Error handling #16427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,6 +101,8 @@ def _handle_amqp_exception_with_condition( | |
| elif condition == AMQPErrorCodes.ClientError and "timed out" in str(exception): | ||
| # handle send timeout | ||
| error_cls = OperationTimeoutError | ||
| elif condition == AMQPErrorCodes.UnknownError and isinstance(exception, AMQPErrors.AMQPConnectionError): | ||
| error_cls = ServiceBusConnectionError | ||
| else: | ||
| # handle other error codes | ||
| error_cls = _ERROR_CODE_TO_ERROR_MAPPING.get(condition, ServiceBusError) | ||
|
|
@@ -491,6 +493,7 @@ class AutoLockRenewTimeout(ServiceBusError): | |
| AMQPErrorCodes.UnauthorizedAccess: ServiceBusAuthorizationError, | ||
| AMQPErrorCodes.NotImplemented: ServiceBusError, | ||
| AMQPErrorCodes.NotAllowed: ServiceBusError, | ||
| AMQPErrorCodes.LinkDetachForced: ServiceBusConnectionError, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What kind of error was this raised as before?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it used to be the general but after contemplating over it, I think this should be categorized into however, the retry would just happen in no-session case. In session case, we don't retry on link/connection failure by design. |
||
| ERROR_CODE_MESSAGE_LOCK_LOST: MessageLockLostError, | ||
| ERROR_CODE_MESSAGE_NOT_FOUND: MessageNotFoundError, | ||
| ERROR_CODE_AUTH_FAILED: ServiceBusAuthorizationError, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import logging | ||
|
|
||
| from uamqp import errors as AMQPErrors, constants as AMQPConstants | ||
| from azure.servicebus.exceptions import ( | ||
| _create_servicebus_exception, | ||
| ServiceBusConnectionError, | ||
| ServiceBusError | ||
| ) | ||
|
|
||
|
|
||
| def test_link_idle_timeout(): | ||
| logger = logging.getLogger("testlogger") | ||
| amqp_error = AMQPErrors.LinkDetach(AMQPConstants.ErrorCodes.LinkDetachForced, description="Details: AmqpMessageConsumer.IdleTimerExpired: Idle timeout: 00:10:00.") | ||
| sb_error = _create_servicebus_exception(logger, amqp_error) | ||
| assert isinstance(sb_error, ServiceBusConnectionError) | ||
| assert sb_error._retryable | ||
| assert sb_error._shutdown_handler | ||
|
|
||
|
|
||
| def test_unknown_connection_error(): | ||
| logger = logging.getLogger("testlogger") | ||
| amqp_error = AMQPErrors.AMQPConnectionError(AMQPConstants.ErrorCodes.UnknownError) | ||
| sb_error = _create_servicebus_exception(logger, amqp_error) | ||
| assert isinstance(sb_error,ServiceBusConnectionError) | ||
| assert sb_error._retryable | ||
| assert sb_error._shutdown_handler | ||
|
|
||
| amqp_error = AMQPErrors.AMQPError(AMQPConstants.ErrorCodes.UnknownError) | ||
| sb_error = _create_servicebus_exception(logger, amqp_error) | ||
| assert not isinstance(sb_error,ServiceBusConnectionError) | ||
| assert isinstance(sb_error,ServiceBusError) | ||
| assert not sb_error._retryable | ||
| assert sb_error._shutdown_handler |
Uh oh!
There was an error while loading. Please reload this page.