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

Commit a7b425d

Browse files
committed
Rename Batch to MessageBatch
1 parent 3f50da5 commit a7b425d

File tree

7 files changed

+37
-38
lines changed

7 files changed

+37
-38
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public interface ISenderClient : IClientEntity
2727

2828
// TODO: extract methods into this interface for the next major version
2929
// /// <summary>
30-
// /// Sends a <see cref="Batch"/> of messages to Service Bus.
30+
// /// Sends a <see cref="MessageBatch"/> of messages to Service Bus.
3131
// /// </summary>
32-
// Task SendAsync(Batch batch);
32+
// Task SendAsync(MessageBatch batch);
3333
// /// <summary>
34-
// /// Create a new <see cref="Batch"/> setting maximum size to the maximum message size allowed by the underlying namespace.
34+
// /// Create a new <see cref="MessageBatch"/> setting maximum size to the maximum message size allowed by the underlying namespace.
3535
// /// </summary>
36-
// Task<Batch> CreateBatch();
36+
// Task<MessageBatch> CreateBatch();
3737

3838
/// <summary>
3939
/// Schedules a message to appear on Service Bus.

src/Microsoft.Azure.ServiceBus/Core/Batch.cs renamed to src/Microsoft.Azure.ServiceBus/Core/MessageBatch.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
// Copyright (c) Microsoft. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System.Threading.Tasks;
5-
64
namespace Microsoft.Azure.ServiceBus.Core
75
{
86
using System;
97
using System.Collections.Generic;
108
using System.Diagnostics;
9+
using System.Threading.Tasks;
1110
using Microsoft.Azure.Amqp;
1211
using Microsoft.Azure.Amqp.Framing;
1312
using Microsoft.Azure.ServiceBus.Amqp;
1413
using Microsoft.Azure.ServiceBus.Diagnostics;
1514

1615
[DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")]
17-
public class Batch : IDisposable
16+
public class MessageBatch : IDisposable
1817
{
1918
internal readonly ulong maximumBatchSize;
2019
private readonly Func<Message, Task<Message>> pluginsCallback;
@@ -32,7 +31,7 @@ public class Batch : IDisposable
3231
/// </summary>
3332
/// <param name="maximumBatchSize">Maximum batch size allowed for batch.</param>
3433
/// <param name="pluginsCallback">Plugins callback to invoke on outgoing messages regisered with batch.</param>
35-
public Batch(ulong maximumBatchSize, Func<Message, Task<Message>> pluginsCallback)
34+
internal MessageBatch(ulong maximumBatchSize, Func<Message, Task<Message>> pluginsCallback)
3635
{
3736
this.maximumBatchSize = maximumBatchSize;
3837
this.pluginsCallback = pluginsCallback;
@@ -86,7 +85,7 @@ public async Task<bool> TryAdd(Message message)
8685
/// Convert batch to AMQP message.
8786
/// </summary>
8887
/// <returns></returns>
89-
public AmqpMessage ToAmqpMessage()
88+
internal AmqpMessage ToAmqpMessage()
9089
{
9190
ThrowIfDisposed();
9291

@@ -135,10 +134,10 @@ private void ThrowIfDisposed()
135134
{
136135
if (result == null)
137136
{
138-
throw new Exception("Batch is has been disposed and cannot be re-used.");
137+
throw new Exception("MessageBatch is has been disposed and cannot be re-used.");
139138
}
140139
}
141140

142-
private string DebuggerDisplay => $"Batch: size={Size} message count={datas.Count} maximum size={maximumBatchSize}";
141+
private string DebuggerDisplay => $"MessageBatch: size={Size}, message count={datas.Count}, maximum size={maximumBatchSize}.";
143142
}
144143
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,13 @@ public async Task SendAsync(IList<Message> messageList)
272272
}
273273

274274
/// <summary>
275-
/// Sends a <see cref="Batch"/> of messages to Service Bus.
275+
/// Sends a <see cref="MessageBatch"/> of messages to Service Bus.
276276
/// </summary>
277-
public async Task SendAsync(Batch batch)
277+
public async Task SendAsync(MessageBatch messageBatch)
278278
{
279279
this.ThrowIfClosed();
280280

281-
MessagingEventSource.Log.MessageSendStart(this.ClientId, batch.Length);
281+
MessagingEventSource.Log.MessageSendStart(this.ClientId, messageBatch.Length);
282282

283283
var isDiagnosticSourceEnabled = ServiceBusDiagnosticSource.IsEnabled();
284284
// TODO: diagnostics (Start/Stop) is currently not possible. Requires change in how Diagnostics works.
@@ -288,7 +288,7 @@ public async Task SendAsync(Batch batch)
288288

289289
try
290290
{
291-
sendTask = this.RetryPolicy.RunOperation(() => this.OnSendAsync(batch.ToAmqpMessage), this.OperationTimeout);
291+
sendTask = this.RetryPolicy.RunOperation(() => this.OnSendAsync(messageBatch.ToAmqpMessage), this.OperationTimeout);
292292
await sendTask.ConfigureAwait(false);
293293
}
294294
catch (Exception exception)
@@ -310,13 +310,13 @@ public async Task SendAsync(Batch batch)
310310
}
311311

312312
/// <summary>
313-
/// Create a new <see cref="Batch"/> setting maximum size to the maximum message size allowed by the underlying namespace.
313+
/// Create a new <see cref="MessageBatch"/> setting maximum size to the maximum message size allowed by the underlying namespace.
314314
/// </summary>
315-
public async Task<Batch> CreateBatch()
315+
public async Task<MessageBatch> CreateBatch()
316316
{
317317
if (maxMessageSize != 0)
318318
{
319-
return new Batch(maxMessageSize, ProcessMessage);
319+
return new MessageBatch(maxMessageSize, ProcessMessage);
320320
}
321321

322322
var timeoutHelper = new TimeoutHelper(this.OperationTimeout, true);
@@ -330,12 +330,12 @@ public async Task<Batch> CreateBatch()
330330

331331
if (!amqpLink.Settings.MaxMessageSize.HasValue)
332332
{
333-
throw new Exception("Broker didn't provide maximum message size. Batch requires maximum message size to operate.");
333+
throw new Exception("Broker didn't provide maximum message size. MessageBatch requires maximum message size to operate.");
334334
}
335335

336336
maxMessageSize = amqpLink.Settings.MaxMessageSize.Value;
337337

338-
return new Batch(maxMessageSize, ProcessMessage);
338+
return new MessageBatch(maxMessageSize, ProcessMessage);
339339
}
340340
catch (Exception exception)
341341
{

src/Microsoft.Azure.ServiceBus/QueueClient.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,19 +350,19 @@ public Task SendAsync(IList<Message> messageList)
350350
}
351351

352352
/// <summary>
353-
/// Sends a <see cref="Batch"/> of messages to Service Bus.
353+
/// Sends a <see cref="MessageBatch"/> of messages to Service Bus.
354354
/// </summary>
355-
public Task SendAsync(Batch batch)
355+
public Task SendAsync(MessageBatch messageBatch)
356356
{
357357
this.ThrowIfClosed();
358358

359-
return this.innerSender.SendAsync(batch);
359+
return this.innerSender.SendAsync(messageBatch);
360360
}
361361

362362
/// <summary>
363-
/// Create a new <see cref="Batch"/> setting maximum size to the maximum message size allowed by the underlying namespace.
363+
/// Create a new <see cref="MessageBatch"/> setting maximum size to the maximum message size allowed by the underlying namespace.
364364
/// </summary>
365-
public Task<Batch> CreateBatch()
365+
public Task<MessageBatch> CreateBatch()
366366
{
367367
this.ThrowIfClosed();
368368

src/Microsoft.Azure.ServiceBus/TopicClient.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,19 @@ public Task SendAsync(IList<Message> messageList)
185185
}
186186

187187
/// <summary>
188-
/// Sends a <see cref="Batch"/> of messages to Service Bus.
188+
/// Sends a <see cref="MessageBatch"/> of messages to Service Bus.
189189
/// </summary>
190-
public Task SendAsync(Batch batch)
190+
public Task SendAsync(MessageBatch messageBatch)
191191
{
192192
this.ThrowIfClosed();
193193

194-
return this.innerSender.SendAsync(batch);
194+
return this.innerSender.SendAsync(messageBatch);
195195
}
196196

197197
/// <summary>
198-
/// Create a new <see cref="Batch"/> setting maximum size to the maximum message size allowed by the underlying namespace.
198+
/// Create a new <see cref="MessageBatch"/> setting maximum size to the maximum message size allowed by the underlying namespace.
199199
/// </summary>
200-
public Task<Batch> CreateBatch()
200+
public Task<MessageBatch> CreateBatch()
201201
{
202202
this.ThrowIfClosed();
203203

test/Microsoft.Azure.ServiceBus.UnitTests/Primitives/BatchTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class BatchTests
1717
[Fact]
1818
public async Task Should_return_false_when_is_about_to_exceed_max_batch_size()
1919
{
20-
using (var batch = new Batch(1, fakePluginsCallback))
20+
using (var batch = new MessageBatch(1, fakePluginsCallback))
2121
{
2222
var wasAdded = await batch.TryAdd(new Message(Encoding.UTF8.GetBytes("hello")));
2323
Assert.False(wasAdded, "Message should not have been added, but it was.");
@@ -27,7 +27,7 @@ public async Task Should_return_false_when_is_about_to_exceed_max_batch_size()
2727
[Fact]
2828
public void Should_throw_if_batch_disposed()
2929
{
30-
using (var batch = new Batch(1, fakePluginsCallback))
30+
using (var batch = new MessageBatch(1, fakePluginsCallback))
3131
{
3232
batch.Dispose();
3333
Assert.ThrowsAsync<Exception>(() => batch.TryAdd(new Message()));
@@ -37,7 +37,7 @@ public void Should_throw_if_batch_disposed()
3737
[Fact]
3838
public void Should_throw_when_trying_to_add_an_already_received_message_to_batch()
3939
{
40-
using (var batch = new Batch(100, fakePluginsCallback))
40+
using (var batch = new MessageBatch(100, fakePluginsCallback))
4141
{
4242
var message = new Message("test".GetBytes());
4343
message.SystemProperties.LockTokenGuid = Guid.NewGuid();
@@ -51,7 +51,7 @@ public void Should_throw_when_trying_to_add_an_already_received_message_to_batch
5151
[InlineData(3)]
5252
public async Task Should_report_how_many_messages_are_in_batch(int numberOfMessages)
5353
{
54-
using (var batch = new Batch(100, fakePluginsCallback))
54+
using (var batch = new MessageBatch(100, fakePluginsCallback))
5555
{
5656
for (var i = 0; i < numberOfMessages; i++)
5757
{
@@ -65,7 +65,7 @@ public async Task Should_report_how_many_messages_are_in_batch(int numberOfMessa
6565
[Fact]
6666
public async Task Should_reflect_property_in_batch_size()
6767
{
68-
using (var batch = new Batch(100, fakePluginsCallback))
68+
using (var batch = new MessageBatch(100, fakePluginsCallback))
6969
{
7070
var message = new Message();
7171

@@ -74,7 +74,7 @@ public async Task Should_reflect_property_in_batch_size()
7474
Assert.Equal((ulong)24, batch.Size);
7575
}
7676

77-
using (var batch = new Batch(100, fakePluginsCallback))
77+
using (var batch = new MessageBatch(100, fakePluginsCallback))
7878
{
7979
var message = new Message();
8080
message.UserProperties["custom"] = "value";

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public async Task ClientsUseGlobalConnectionCloseFirstClientSecoundClientShouldS
474474
var message2 = new Message("from".GetBytes());
475475
var message3 = new Message("Sean Feldman".GetBytes());
476476

477-
var batch = new Batch(100, Task.FromResult);
477+
var batch = new MessageBatch(100, Task.FromResult);
478478
Assert.True(await batch.TryAdd(message1), "Couldn't add first message");
479479
Assert.True(await batch.TryAdd(message2), "Couldn't add second message");
480480
Assert.False(await batch.TryAdd(message3), "Shouldn't be able to add third message");
@@ -508,7 +508,7 @@ public async Task Sending_batch_with_properties()
508508
var message = new Message("Hello Neeraj".GetBytes());
509509
message.UserProperties["custom"] = "value";
510510

511-
var batch = new Batch(100, Task.FromResult);
511+
var batch = new MessageBatch(100, Task.FromResult);
512512
Assert.True(await batch.TryAdd(message), "Couldn't add message");
513513
await sender.SendAsync(batch);
514514
batch.Dispose();

0 commit comments

Comments
 (0)