Add expire_conn for service bus connection failures #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In a recent PR (#1), we expired Eventhub connections from the ManagedEventhubProducer if there were connection issues using those connections. At the time, we noted that this work should also be applied for the ServiceBusSender connections as well in that Managed client.
This PR includes the call to the
ConnectionPool.expire_conn
method when any of the following exceptions are thrown while trying to schedule a message with the connection:ServiceBusCommunicationError
ServiceBusAuthorizationError
ServiceBusAuthenticationError
ServiceBusConnectionError
All of the above imported from
azure.servicebus.exceptions
.It's possible in the future that we will want to amend the list of exceptions that can cause us to expire connections: from reading the docstrings on the exceptions in this module, it seemed like some of the others could also apply. For now, we're using the above.
This test also improves test coverage for the
service_bus
module, including new tests for theManagedAzureServiceBusSender
class (no tests covered this class previously).