Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 50ce0c5

Browse files
authored
Merge from dev
2 parents a920fbf + 67eee1f commit 50ce0c5

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/Microsoft.Azure.ServiceBus/Core/MessageSender.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ internal MessageSender(
153153

154154
this.ServiceBusConnection = serviceBusConnection ?? throw new ArgumentNullException(nameof(serviceBusConnection));
155155
this.Path = entityPath;
156+
this.TransferDestinationPath = transferDestinationPath;
156157
this.EntityType = entityType;
157158

158159
if (cbsTokenProvider != null)
@@ -193,6 +194,11 @@ internal MessageSender(
193194
/// </summary>
194195
public override string Path { get; }
195196

197+
/// <summary>
198+
/// Gets the transfer destination path (send-via) of the MessageSender.
199+
/// </summary>
200+
public string TransferDestinationPath { get; }
201+
196202
/// <summary>
197203
/// Duration after which individual operations will timeout.
198204
/// </summary>

test/Microsoft.Azure.ServiceBus.UnitTests/API/ApiApprovals.ApproveAzureServiceBus.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ namespace Microsoft.Azure.ServiceBus.Core
541541
public override string Path { get; }
542542
public override System.Collections.Generic.IList<Microsoft.Azure.ServiceBus.Core.ServiceBusPlugin> RegisteredPlugins { get; }
543543
public override Microsoft.Azure.ServiceBus.ServiceBusConnection ServiceBusConnection { get; }
544+
public string TransferDestinationPath { get; }
544545
public System.Threading.Tasks.Task CancelScheduledMessageAsync(long sequenceNumber) { }
545546
protected override System.Threading.Tasks.Task OnClosingAsync() { }
546547
public override void RegisterPlugin(Microsoft.Azure.ServiceBus.Core.ServiceBusPlugin serviceBusPlugin) { }

test/Microsoft.Azure.ServiceBus.UnitTests/TransactionTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public async Task TransactionalSendRollbackTest(string queueName)
7777
ts.Dispose();
7878
}
7979

80+
// Adding delay since transaction Commit/Rollback is an asynchronous operation.
81+
// Operating on the same message should not be done.
82+
await Task.Delay(TimeSpan.FromSeconds(2));
83+
8084
var receivedMessage = await receiver.ReceiveAsync(ReceiveTimeout);
8185
Assert.Null(receivedMessage);
8286
}
@@ -148,6 +152,10 @@ public async Task TransactionalCompleteRollbackTest(string queueName)
148152
ts.Dispose();
149153
}
150154

155+
// Adding delay since transaction Commit/Rollback is an asynchronous operation.
156+
// Operating on the same message should not be done.
157+
await Task.Delay(TimeSpan.FromSeconds(2));
158+
151159
await receiver.CompleteAsync(receivedMessage.SystemProperties.LockToken);
152160
}
153161
finally
@@ -197,6 +205,8 @@ public async Task TransactionalSessionDispositionTest(string queueName)
197205
ts.Complete();
198206
}
199207

208+
// Adding delay since transaction Commit/Rollback is an asynchronous operation.
209+
// Operating on the same message should not be done.
200210
await Task.Delay(TimeSpan.FromSeconds(2));
201211

202212
await Assert.ThrowsAsync<SessionLockLostException>(async () => await receiver.CompleteAsync(receivedMessage.SystemProperties.LockToken));
@@ -240,12 +250,20 @@ public async Task TransactionalRequestResponseDispositionTest(string queueName)
240250
ts.Dispose();
241251
}
242252

253+
// Adding delay since transaction Commit/Rollback is an asynchronous operation.
254+
// Operating on the same message should not be done.
255+
await Task.Delay(TimeSpan.FromSeconds(2));
256+
243257
using (var ts = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
244258
{
245259
await receiver.CompleteAsync(deferredMessage.SystemProperties.LockToken);
246260
ts.Complete();
247261
}
248262

263+
// Adding delay since transaction Commit/Rollback is an asynchronous operation.
264+
// Operating on the same message should not be done.
265+
await Task.Delay(TimeSpan.FromSeconds(2));
266+
249267
await Assert.ThrowsAsync<MessageLockLostException>(async () => await receiver.CompleteAsync(deferredMessage.SystemProperties.LockToken));
250268
}
251269
finally
@@ -285,7 +303,12 @@ await Assert.ThrowsAsync<InvalidOperationException>(
285303
async () => await sender.SendAsync(message2));
286304
ts.Complete();
287305
}
306+
288307
transaction.Rollback();
308+
309+
// Adding delay since transaction Commit/Rollback is an asynchronous operation.
310+
// Operating on the same message should not be done.
311+
await Task.Delay(TimeSpan.FromSeconds(2));
289312

290313
// Two complete operations to different partitions.
291314
await sender.SendAsync(message1);
@@ -308,6 +331,10 @@ await Assert.ThrowsAsync<InvalidOperationException>(
308331

309332
transaction.Rollback();
310333

334+
// Adding delay since transaction Commit/Rollback is an asynchronous operation.
335+
// Operating on the same message should not be done.
336+
await Task.Delay(TimeSpan.FromSeconds(2));
337+
311338
await receiver.CompleteAsync(receivedMessage1.SystemProperties.LockToken);
312339
await receiver.CompleteAsync(receivedMessage2.SystemProperties.LockToken);
313340
}
@@ -349,6 +376,10 @@ public async Task TransactionCommitWorksAcrossClientsUsingSameConnectionToSameEn
349376
ts.Complete();
350377
}
351378

379+
// Adding delay since transaction Commit/Rollback is an asynchronous operation.
380+
// Operating on the same message should not be done.
381+
await Task.Delay(TimeSpan.FromSeconds(2));
382+
352383
// Assert that complete did succeed
353384
await Assert.ThrowsAsync<MessageLockLostException>(async () => await receiver.CompleteAsync(receivedMessage.SystemProperties.LockToken));
354385

@@ -393,6 +424,10 @@ public async Task TransactionRollbackWorksAcrossClientsUsingSameConnectionToSame
393424
ts.Dispose();
394425
}
395426

427+
// Adding delay since transaction Commit/Rollback is an asynchronous operation.
428+
// Operating on the same message should not be done.
429+
await Task.Delay(TimeSpan.FromSeconds(2));
430+
396431
// Following should succeed without exceptions
397432
await receiver.CompleteAsync(receivedMessage.SystemProperties.LockToken);
398433

0 commit comments

Comments
 (0)