Introduces transaction support.
Operations can now be executed inside a TransactionScope providing atomicity.
Supported operations for transactions:
`SendAsync`, `CompleteAsync`, `DeferAsync`, `DeadLetterAsync`, `AbandonAsync`
Transaction cannot work across connections. Hence, to be able to Send and Receive in a single transaction, `ServiceBusConnection` object has been exposed. Each of the client entities now accepts an already created connection.
Sample usage:
```csharp
var connection = new ServiceBusConnection(ConnectionString);
var sender = new MessageSender(connection, QueueName);
var receiver = new MessageReceiver(connection, QueueName);
var receivedMessage = await receiver.ReceiveAsync();
using (var ts = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
{
await receiver.CompleteAsync(receivedMessage.SystemProperties.LockToken);
await sender.SendAsync(message).ConfigureAwait(false);
ts.Complete();
// Or, ts.Dispose();
}
await sender.CloseAsync();
await receiver.CloseAsync();
await connection.CloseAsync();
```
Fixes#432 (Microsoft.Azure.Amqp tight to a specific version).
* Add a range to AMQP dependency package
* Add range for Microsoft.IdentityModel.Clients.ActiveDirectory
If you don't set a TTL on a message, it gets a value of TimeSpan.MaxValue.
The code that converts it to an Ampq message was checking whether
message.TimeToLive was null rather than if it was equal to TimeSpan.MaxValue.
Now, if it's equal to TimeSpan.MaxValue, it will use the Default value
set on the Entity.
This fixes#424
* Adding associatedlinkname application property to request-response requests so that they can be associated with proper publisher or consumer on the service.
* Changing ReceiveLinkManager access from protected to internal
1. Updated references to latest amqp and other packages. #336
1. Updated resource string for exception. #375
1. Added retry logic for cbs token renewal to make it more resilient to network issues. #378
1. Updated bug where `CbsTokenProvider` was not initialized properly. #359 (Thanks @Aleksanderis)
1. Support for custom token providers which was added for few clients has been extended to `MessageSender`, `MessageReceiver` and `SessionClient`
1. Minor cleanup.
Fixes#407 by replacing string interpolation with regular string.Format() and CultureInfo.CurrentCulture.
Added unit test to cover a few scenarios, including no message ID.
* using xunit compatible reporter
* filtering TargetFrameworkAttribute assembly attribute as it's framework specific
* no longer including TargetFrameworkAttribute in the approved API
* update dependencies for test project
* Moving reporter configuration to a separate file
* Reduce checkin tests execution time so build jobs on appveyor can complete
* Addressing Review Comments, moved the conditional complile to the test proj file
* Use .netcoreapp framework instead of .netstandard framework
* Remove Diagnostic Tests as well
* Trying to fix a flaky test
* Disable the flaky Test
* Disable and another flaky test
* Reduce checkin tests execution time so build jobs on appveyor can complete
* Addressing Review Comments, moved the conditional complile to the test proj file
* Use .netcoreapp framework instead of .netstandard framework
* Remove Diagnostic Tests as well
* Wiring up AAD token providers
* Addressing Vinay's comments.
* Build failure fix
* Removing extra overloads.
* Remove unnecessary default internal constructor in SecurityToken
* Pass temporary audience instead of empty string to SecurityToken.
* Make token type required
* Refactoring SharedAccessSignatureToken for cleanup
* Remove unnecessary usings
* Function renaming to carry UTC notion.
* Changes for ApiApproval
* Remove procted accesors from SecurityToken class properties.
* ApiApproval run after moving fields to private.
Fixes#373. This makes the constructors for exception classes public, so that when interfaces such as IQueueClient are mocked for unit testing, the mocks can throw the correct exceptions.
This change adds instrumentation with `DiagnosticSource` for public ServiceBus APIs:
- `MessageSender` (i.e. `QueueClient` and `TopicClient`): `SendAsync`, `ScueduleMessage` and `Cancel`
- `MessageReceiver`: `Receive`, `ReceiveDeffered`, `Peek`, `Abandon`, `Defer`, `Complete`, `DeadLetter`, `RenewLock`
- `MessageSession`: `AcceptMessageSession`
- `SubscriptionClient` : `AddRule`, `RemoveRule`, `GetRules`
- Message and session handlers
Tracing system (e.g. ApplicationInsights) may subscribe to ServiceBus DiagnosticSource and receive events about these operations including tracing context needed to correlate events and log any important information.
In absence of tracing system, diagnostics is disabled and performance cost of having it is ~zero.
We also introduce here telemetry correlation between producer and consumer: when diagnostics is enabled on a consumer, tracing context is injected into the message. When a producer receives such message, it extracts and restores context making it available for tracing system.
This also adds `Message.ExtractActivity()` public extension method that allows extracting the context from a message that is useful when handler API is NOT used to process messages.
Note: this change introduces 'standard' fields to pass tracing context through the queues to correlate telemetry:
`Diagnostic-Id` - uniquely identifies operation that sent message(s) to the queue
`Correlation-Context` - optional extended context (empty by default)
This is pretty similar to [HTTP Correlation protocol](https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md) implemented in .NET HTTP stack.
Users are encouraged to use these properties on all platforms, not only .NET.
As a result of this change, a tracing system may enable diagnostics information and receive events it's interested in making sure tracing context is propagated through the service bus, without ANY changes in user code (except for non-handler processing).
-------
Instrumentation approach backgound:
- [Activity UserGuide](https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/ActivityUserGuide.md)
- [DiagnosticSource UserGuide](https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/DiagnosticSourceUsersGuide.md)
- [.NET HTTP Client instrumentation](https://github.com/dotnet/corefx/blob/master/src/System.Net.Http/src/HttpDiagnosticsGuide.md)
- [HTTP Correlation protocol](https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md)
- [EventHub .NET Client instrumentation (WIP)](8f934200e9)
We had logic written in MessageReceiver.ReceiveAsync() to filter out expired messages before returning the message to the user. This might lead to problems when there is a machine time difference between the ASB service and the client machine which may lead to never receiving a message.
Removing this "smart" handling of expired messages.
If the prefetch count is high, customers can receive messages from the prefetched queue which are already expired. This also helps customers in calculating the optimal prefetch count. If they receive expired messages, then the prefetch count needs to be re-looked at.
* Added overload for deadletterAsync to specify dead letter reason
* Added overload for deadletter/abandon/defer to take properties that needs to be updated.
Resolves#339
Updating client version to 2.0 since we have a breaking change (Interface changes in IMessageReceiver)
Bumping up dotnet framework version to netstandard 2.0. net 46 is required for functioning of web sockets
We create a new amqp-session on which we open links. But if link creation fails, we should close the session as it is not re-used again. These sessions are mapped to a session handle table on backend which keeps track of these open sessions. Once we hit 5000 open sessions, backend throws QuotaExceededException.
Fixes#237