fix(ServiceBus): Read max-message-batch-size vendor property for batch sizing#57941
Merged
EldertGrootenboer merged 5 commits intoApr 8, 2026
Conversation
…h sizing - Read com.microsoft:max-message-batch-size from AMQP sender link properties to correctly limit batch size on Premium large-message entities where max-message-size can be up to 100 MB but the batch limit is 1 MB - Remove hardcoded 4,500 message count cap; the service has no count limit and the byte size limit naturally caps message count - Falls back to DefaultMaxBatchSize (1 MB) when vendor property is absent (backward compatibility) - Add unit tests for vendor property scenarios (Premium large-message, Standard tier, absent fallback, count cap removal)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Service Bus AMQP sender to size message batches using the broker-provided vendor link property (com.microsoft:max-message-batch-size) rather than relying on the link’s max-message-size, addressing incorrect batching behavior for Premium large-message entities.
Changes:
- Add a new AMQP vendor property constant for
com.microsoft:max-message-batch-size. - Update
AmqpSenderto read the vendor batch-size limit from the sender link attach properties (with fallback to the existing 1 MB default) and remove the previous 4,500 message count cap. - Add unit tests covering vendor-property-based batch sizing, fallback behavior, and count-cap removal.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/servicebus/Azure.Messaging.ServiceBus/src/Amqp/AmqpClientConstants.cs | Adds the AMQP symbol constant for the vendor batch-size link property. |
| sdk/servicebus/Azure.Messaging.ServiceBus/src/Amqp/AmqpSender.cs | Uses the vendor link property to set MaxBatchSize and removes the default message-count cap wiring. |
| sdk/servicebus/Azure.Messaging.ServiceBus/tests/Amqp/AmqpSenderTests.cs | Adds tests for vendor-property sizing behavior and verifies removal of the message-count limit. |
- Use 10 MB batch limit in count cap test to ensure all 6000 messages fit regardless of AMQP envelope overhead variations
jsquire
reviewed
Apr 8, 2026
…ge test helper - Trim verbose vendor property comment to avoid staleness - Use link.Settings?.Properties.TryGetValue instead of explicit null check - Merge SetLinkLimitsWithBatchSize into SetLinkLimits with optional maxBatchSize param
jsquire
approved these changes
Apr 8, 2026
jsquire
approved these changes
Apr 8, 2026
haiyuazhang
pushed a commit
that referenced
this pull request
Apr 14, 2026
…h sizing (#57941) * fix(ServiceBus): Read max-message-batch-size vendor property for batch sizing - Read com.microsoft:max-message-batch-size from AMQP sender link properties to correctly limit batch size on Premium large-message entities where max-message-size can be up to 100 MB but the batch limit is 1 MB - Remove hardcoded 4,500 message count cap; the service has no count limit and the byte size limit naturally caps message count - Falls back to DefaultMaxBatchSize (1 MB) when vendor property is absent (backward compatibility) - Add unit tests for vendor property scenarios (Premium large-message, Standard tier, absent fallback, count cap removal) * fix: address Copilot review - robust count cap test - Use 10 MB batch limit in count cap test to ensure all 6000 messages fit regardless of AMQP envelope overhead variations * fix: address jsquire review - simplify comment, null-conditional, merge test helper - Trim verbose vendor property comment to avoid staleness - Use link.Settings?.Properties.TryGetValue instead of explicit null check - Merge SetLinkLimitsWithBatchSize into SetLinkLimits with optional maxBatchSize param * docs: add CHANGELOG entry for batch size vendor property fix --------- Co-authored-by: Eldert Grootenboer (from Dev Box) <egrootenboer@microsoft.com>
EldertGrootenboer
added a commit
to Azure/azure-sdk-for-js
that referenced
this pull request
May 8, 2026
…ch sizing (#38049) ## Problem On Premium large-message Service Bus entities, the AMQP link's `max-message-size` can be up to 100 MB, but the broker enforces a 1 MB limit for batch sends. The JS SDK reads `max-message-size` (via `this.link.maxMessageSize`) for batch sizing, so `createMessageBatch()` accepts batches up to 100 MB that the broker then rejects. Related: [azure-service-bus#708](Azure/azure-service-bus#708) ## Fix Read the `com.microsoft:max-message-batch-size` vendor property from the AMQP sender link attach frame, which correctly reports 256 KB (Standard) / 1 MB (Premium) independent of entity-level `max-message-size`. When the vendor property is absent (older service versions), fall back to `Math.min(maxMessageSize, defaultMaxBatchSize)` where `defaultMaxBatchSize` is 1 MB — this caps the batch size to prevent using the raw `max-message-size` (which can be up to 100 MB on Premium large-message entities). ### Changes - **`messageSender.ts`**: Add `defaultMaxBatchSize` constant (1 MB); add `getMaxBatchSizeFromLink()` that reads the vendor property from `this.link.properties`, falling back to `Math.min(maxMessageSize, defaultMaxBatchSize)`; update `createBatch()` to use the new method - **`messageSender.spec.ts`**: Unit tests for vendor property present, absent (with 1 MB cap), undefined properties, wrong type, zero value, user override, rejection of oversized `maxSizeInBytes`, Standard tier ### Cross-SDK alignment | SDK | Status | |-----|--------| | .NET | [PR #57941](Azure/azure-sdk-for-net#57941) | | Java | [PR #48214](Azure/azure-sdk-for-java#48214) | | Go | [PR #26530](Azure/azure-sdk-for-go#26530) | | Python | [PR #46197](Azure/azure-sdk-for-python#46197) | --------- Co-authored-by: Eldert Grootenboer (from Dev Box) <egrootenboer@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Premium large-message Service Bus entities, the AMQP link's
max-message-sizecan be up to 100 MB, but the broker enforces a 1 MB limit for batch sends. The .NET SDK hardcodesDefaultMaxBatchSize = 1048576(1 MB) andMaxMessageCount = 4500as a workaround — correct behavior but not reading from the link property.Related: #44914, #44916, azure-service-bus#708
Fix
Read the
com.microsoft:max-message-batch-sizevendor property from the AMQP sender link attach frame, which the service now correctly reports as 256 KB (Standard) / 1 MB (Premium) independent of entity-levelmax-message-size. Fall back toDefaultMaxBatchSize(1 MB) when the vendor property is absent. Remove the 4,500 message count cap — the service has no count limit, and the byte size limit naturally caps count.Changes
AmqpClientConstants.cs: AddMaxMessageBatchSizeNameconstant forcom.microsoft:max-message-batch-sizeAmqpSender.cs: Read vendor property vialink.Settings.Properties.TryGetValue<long>(); removeMaxMessageCountproperty and 4,500 defaultAmqpSenderTests.cs: 4 new tests: vendor property on Premium large-message (100 MB entity → 1 MB batch), Standard tier (256 KB), absent fallback, count cap removal (>4500 messages fit in byte-limited batch)Resolves #44914. Related to #44916.
Cross-SDK alignment