Appendix: Messaging Exceptions
This section lists the various exceptions generated by the Service Bus messaging API. This reference is subject to change, so check back for updates.
Exception Categories
The messaging API generate exceptions that can fall into the following categories, with the associated action you can take to try to fix them:
-
User code error (ArgumentException, InvalidOperationException, OperationCanceledException, SerializationException). General action: try to fix the code before proceeding.
-
Setup/configuration error (MessagingEntityNotFoundException, UnauthorizedAccessException. General action: review your configuration and change if necessary.
-
Transient exceptions (MessagingException, ServerBusyException, MessagingCommunicationException). General action: retry the operation or notify users.
-
Other exceptions (TransactionException, TimeoutException, MessageLockLostException/SessionLockLostException). General action: you generally do not handle these exceptions to perform cleanup or aborts. They might be used for tracing.
Exception Types
The following table lists messaging exception types, and their causes, and notes suggested action you can take.
| Exception Type | Description/Cause/Examples | Suggested Action | Note on automatic/immediate retry |
|---|---|---|---|
|
The server did not respond to the requested operation within the specified time which is controlled by OperationTimeout. The server may have completed the requested operation.This can happen due to network or other infrastructure delays. |
Check the system state for consistency and retry if necessary. |
Retry might help in some cases; add retry logic to code. |
|
|
The requested user operation is not allowed within the server or service. See the exception message for details. For example, Complete will generate this exception if the message was received in ReceiveAndDelete mode. |
Check the code and the documentation. Make sure the requested operation is valid. |
Retry will not help. |
|
|
An attempt is made to invoke an operation on an object that has already been closed, aborted or disposed.In rare cases, the ambient transaction is already disposed. |
Check the code and make sure it does not invoke operations on a disposed object. |
Retry will not help. |
|
|
The TokenProvider object could not acquire a token, the token is invalid, or the token does not contain the claims required to perform the operation. |
Make sure the token provider is created with the correct values. Check the configuration of the Access Control service. |
Retry might help in some cases; add retry logic to code. |
|
|
Check the calling code and make sure the arguments are correct. |
Retry will not help. |
|
|
Entity associated with the operation does not exist or it has been deleted. |
Make sure the entity exists. |
Retry will not help. |
|
|
Attempt to receive a message with a particular sequence number. This message is not found. |
Make sure the message has not been received already. Check the deadletter queue to see if the message has been deadlettered. |
Retry will not help. |
|
|
Client is not able to establish a connection to the Service Bus. |
Make sure the supplied host name is correct and the host is reachable. |
Retry might help if there are intermittent connectivity issues. |
|
|
Service is not able to process the request at this time. |
Client can wait for a period of time, then retry the operation. |
Client may retry after certain interval. If a retry results in a different exception, check retry behavior of that exception. |
|
|
Lock token associated with the message has expired or the lock token is not found. |
Dispose the message. |
Retry will not help. |
|
|
Lock associated with this session is lost. |
Abort the MessageSession object. |
Retry will not help. |
|
|
Generic messaging exception that may be thrown in the following cases:
|
|
Retry behavior is undefined and might not help. |
|
|
Attempt to create an entity with a name that is already used by another entity in that service namespace. |
Delete the existing entity or choose a different name for the entity to be created. |
Retry will not help. |
|
|
The messaging entity has reached its maximum allowable size. |
Create space in the entity by receiving messages from the entity or its sub-queues. |
Retry might help if messages have been removed in the meantime. |
|
|
The Service Bus returns this exception if you attempt to create an invalid rule action. The Service Bus attaches this exception to a deadlettered message if an error occurs while processing the rule action for that message. |
Check the rule action for correctness. |
Retry will not help. |
|
|
The Service Bus returns this exception if you attempt to create an invalid filter. The Service Bus attaches this exception to a deadlettered message if an error occurred while processing the filter for that message. |
Check the filter for correctness. |
Retry will not help. |
|
|
Attempt to accept a session with a specific session ID, but the session is currently locked by another client. |
Make sure the session is unlocked by other clients. |
Retry might help if the session has been released in the interim. |
|
|
Too many operations are part of the transaction. |
Reduce the number of operations that are part of this transaction. |
Retry will not help. |
|
|
Request for a runtime operation on a disabled entity. |
Activate the entity. |
Retry might help if the entity has been activated in the interim. |
|
|
The Service Bus returns this exception if the user sends a message to a topic that has pre-filtering enabled and none of the filters match. |
Make sure at least one filter matches. |
Retry will not help. |
|
|
The ambient transaction (Current) is invalid. It may have been completed or aborted. Inner exception may provide additional information. |
|
Retry will not help. |
|
|
An operation is attempted on a transaction that is in doubt, or an attempt is made to commit the transaction and the transaction becomes in doubt. |
You application must handle this exception (as a special case), as the transaction may have already been committed. |
|