Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e3b2ef6
Cap ServiceBusMessageBatch size at 1 MB to match broker enforcement
EldertGrootenboerMS Mar 4, 2026
d227063
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
EldertGrootenboerMS Mar 5, 2026
9b125cc
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
EldertGrootenboerMS Mar 10, 2026
3dcbd2e
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
EldertGrootenboerMS Mar 11, 2026
884f69a
Merge branch 'main' into fix/servicebus-batch-size-cap-ICM51000000793879
EldertGrootenboer Mar 16, 2026
2a86c2e
Merge branch 'main' into fix/servicebus-batch-size-cap-ICM51000000793879
EldertGrootenboer Mar 16, 2026
8d0687e
Merge branch 'main' into fix/servicebus-batch-size-cap-ICM51000000793879
EldertGrootenboer Mar 18, 2026
1b80911
Read max-message-batch-size vendor property for batch sizing
EldertGrootenboerMS Apr 8, 2026
fba6852
Improve error message to say 'maximum batch size' instead of 'maximum…
EldertGrootenboerMS Apr 8, 2026
1e8aa33
Update MAX_MESSAGE_LENGTH_BYTES JavaDoc to reflect actual usage as li…
EldertGrootenboerMS Apr 8, 2026
11a132d
Merge branch 'main' into fix/servicebus-batch-size-cap-ICM51000000793879
EldertGrootenboer Apr 8, 2026
8671b03
Rename test to createBatchUsesVendorBatchSizeOnStandardNamespace for …
EldertGrootenboerMS Apr 8, 2026
e6e0150
Clarify JavaDoc on default getMaxBatchSize(), rename maximumLinkSize …
EldertGrootenboerMS Apr 8, 2026
bdb3e03
fix: use unreleased dependency versioning for azure-core-amqp
EldertGrootenboerMS Apr 9, 2026
0533c68
fix: clarify fallback log message to include non-positive case
EldertGrootenboerMS Apr 9, 2026
4334499
fix: correct constant name in test javadocs
EldertGrootenboerMS Apr 9, 2026
73b9e0a
Merge remote-tracking branch 'origin/main' into fix/servicebus-batch-…
EldertGrootenboerMS May 8, 2026
00e7dff
test: avoid single-use Stream in scheduleMessages mock
EldertGrootenboerMS May 8, 2026
2a91153
Merge branch 'main' into fix/servicebus-batch-size-cap-ICM51000000793879
EldertGrootenboer May 8, 2026
0ba9330
Merge branch 'main' into fix/servicebus-batch-size-cap-ICM51000000793879
EldertGrootenboer May 8, 2026
9df04e6
Merge branch 'main' into fix/servicebus-batch-size-cap-ICM51000000793879
EldertGrootenboer May 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ public final class ServiceBusSenderAsyncClient implements AutoCloseable {
* The default maximum allowable size, in bytes, for a batch to be sent.
Comment thread
EldertGrootenboer marked this conversation as resolved.
Outdated
*/
static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
// Temporary workaround: Service Bus enforces a maximum batch payload size of 1 MB that is not
// communicated via the AMQP link's max-message-size property. The link reports the per-message
// limit (up to 100 MB for Premium partitioned), but the broker rejects batch sends above 1 MB.
// This cap is applied only in createMessageBatch(), which is the single enforcement point for
// batch size limits. The sendMessages(iterable) and scheduleMessages(iterable) paths use
// createMessageBatch() internally and are therefore also capped. Single-message paths
// (sendMessage, scheduleMessage) are not capped since individual messages on Premium can
// validly exceed 1 MB up to the per-entity limit.
// Tracked by: https://github.com/Azure/azure-service-bus/issues/708
static final int MAX_BATCH_SIZE_BYTES = 1024 * 1024;
private static final String TRANSACTION_LINK_NAME = "coordinator";
private static final ServiceBusMessage END = new ServiceBusMessage(new byte[0]);
private static final CreateMessageBatchOptions DEFAULT_BATCH_OPTIONS = new CreateMessageBatchOptions();
Expand Down Expand Up @@ -463,15 +473,15 @@ public Mono<ServiceBusMessageBatch> createMessageBatch(CreateMessageBatchOptions
final int maxSize = options.getMaximumSizeInBytes();

return getSendLinkWithRetry("create-batch").flatMap(link -> link.getLinkSize().flatMap(size -> {
final int maximumLinkSize = size > 0 ? size : MAX_MESSAGE_LENGTH_BYTES;
final int maximumLinkSize = Math.min(size > 0 ? size : MAX_MESSAGE_LENGTH_BYTES, MAX_BATCH_SIZE_BYTES);
if (maxSize > maximumLinkSize) {
return monoError(logger,
new IllegalArgumentException(String.format(Locale.US,
"CreateMessageBatchOptions.getMaximumSizeInBytes (%s bytes) is larger than the link size"
+ " (%s bytes).",
"CreateMessageBatchOptions.getMaximumSizeInBytes (%s bytes) is larger than the maximum"
+ " allowed size (%s bytes).",
maxSize, maximumLinkSize)));
}
final int batchSize = maxSize > 0 ? maxSize : maximumLinkSize;
final int batchSize = maxSize > 0 ? Math.min(maxSize, maximumLinkSize) : maximumLinkSize;
return Mono
.just(new ServiceBusMessageBatch(isV2, batchSize, link::getErrorContext, tracer, messageSerializer));
})).onErrorMap(this::mapError);
Expand Down
Loading