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

Commit 4629430

Browse files
committed
Adding batched send to QueueClient and TopicClient
1 parent 4292a5b commit 4629430

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public interface ISenderClient : IClientEntity
2525
/// </summary>
2626
Task SendAsync(IList<Message> messageList);
2727

28+
// TODO: extract method into this interface for the next major version
29+
// /// <summary>
30+
// /// Sends a <see cref="Batch"/> of messages to Service Bus.
31+
// /// </summary>
32+
// Task SendAsync(Batch batch);
33+
2834
/// <summary>
2935
/// Schedules a message to appear on Service Bus.
3036
/// </summary>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ public async Task SendAsync(IList<Message> messageList)
267267

268268
MessagingEventSource.Log.MessageSendStop(this.ClientId);
269269
}
270+
271+
/// <summary>
272+
/// Sends a <see cref="Batch"/> of messages to Service Bus.
273+
/// </summary>
270274
public async Task SendAsync(Batch batch)
271275
{
272276
this.ThrowIfClosed();

src/Microsoft.Azure.ServiceBus/QueueClient.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public QueueClient(string connectionString, string entityPath, ReceiveMode recei
8989
{
9090
throw Fx.Exception.ArgumentNullOrWhiteSpace(connectionString);
9191
}
92-
92+
9393
this.OwnsConnection = true;
9494
}
9595

@@ -328,7 +328,7 @@ internal SessionPumpHost SessionPumpHost
328328
return this.sessionPumpHost;
329329
}
330330
}
331-
331+
332332
ICbsTokenProvider CbsTokenProvider { get; }
333333

334334
/// <summary>
@@ -349,6 +349,16 @@ public Task SendAsync(IList<Message> messageList)
349349
return this.InnerSender.SendAsync(messageList);
350350
}
351351

352+
/// <summary>
353+
/// Sends a <see cref="Batch"/> of messages to Service Bus.
354+
/// </summary>
355+
public Task SendAsync(Batch batch)
356+
{
357+
this.ThrowIfClosed();
358+
359+
return this.innerSender.SendAsync(batch);
360+
}
361+
352362
/// <summary>
353363
/// Completes a <see cref="Message"/> using its lock token. This will delete the message from the queue.
354364
/// </summary>

src/Microsoft.Azure.ServiceBus/TopicClient.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ internal MessageSender InnerSender
164164
return this.innerSender;
165165
}
166166
}
167-
167+
168168
ICbsTokenProvider CbsTokenProvider { get; }
169169

170170
/// <summary>
@@ -184,6 +184,16 @@ public Task SendAsync(IList<Message> messageList)
184184
return this.InnerSender.SendAsync(messageList);
185185
}
186186

187+
/// <summary>
188+
/// Sends a <see cref="Batch"/> of messages to Service Bus.
189+
/// </summary>
190+
public Task SendAsync(Batch batch)
191+
{
192+
this.ThrowIfClosed();
193+
194+
return this.innerSender.SendAsync(batch);
195+
}
196+
187197
/// <summary>
188198
/// Schedules a message to appear on Service Bus at a later time.
189199
/// </summary>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ namespace Microsoft.Azure.ServiceBus
238238
public System.Threading.Tasks.Task<long> ScheduleMessageAsync(Microsoft.Azure.ServiceBus.Message message, System.DateTimeOffset scheduleEnqueueTimeUtc) { }
239239
public System.Threading.Tasks.Task SendAsync(Microsoft.Azure.ServiceBus.Message message) { }
240240
public System.Threading.Tasks.Task SendAsync(System.Collections.Generic.IList<Microsoft.Azure.ServiceBus.Message> messageList) { }
241+
public System.Threading.Tasks.Task SendAsync(Microsoft.Azure.ServiceBus.Core.Batch batch) { }
241242
public override void UnregisterPlugin(string serviceBusPluginName) { }
242243
}
243244
public sealed class QuotaExceededException : Microsoft.Azure.ServiceBus.ServiceBusException
@@ -453,6 +454,7 @@ namespace Microsoft.Azure.ServiceBus
453454
public System.Threading.Tasks.Task<long> ScheduleMessageAsync(Microsoft.Azure.ServiceBus.Message message, System.DateTimeOffset scheduleEnqueueTimeUtc) { }
454455
public System.Threading.Tasks.Task SendAsync(Microsoft.Azure.ServiceBus.Message message) { }
455456
public System.Threading.Tasks.Task SendAsync(System.Collections.Generic.IList<Microsoft.Azure.ServiceBus.Message> messageList) { }
457+
public System.Threading.Tasks.Task SendAsync(Microsoft.Azure.ServiceBus.Core.Batch batch) { }
456458
public override void UnregisterPlugin(string serviceBusPluginName) { }
457459
}
458460
public enum TransportType

0 commit comments

Comments
 (0)