fix(azservicebus): Read max-message-batch-size vendor property for batch sizing#26530
Open
EldertGrootenboer wants to merge 5 commits intoAzure:mainfrom
Open
Conversation
…tch 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 - Add Properties() method to AMQPSender interface, matching the existing pattern on AMQPReceiver - Falls back to MaxMessageSize() when vendor property is absent - Add unit tests for vendor property override, absent fallback, and user MaxBytes override
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Sender.NewMessageBatch() sizing for Service Bus entities that support large message sizes by reading the AMQP sender link’s vendor property com.microsoft:max-message-batch-size (broker-enforced batch limit), falling back to MaxMessageSize() when absent.
Changes:
- Prefer
com.microsoft:max-message-batch-sizeoverMaxMessageSize()when computing the defaultMessageBatchmax size. - Extend the
AMQPSenderabstraction (and mocks/fakes) with aProperties()accessor to expose link attach properties. - Add unit tests covering vendor-property override, fallback behavior, and user
MaxBytesoverride.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/messaging/azservicebus/sender.go | Use sender link properties to pick the correct batch size limit (vendor property preferred). |
| sdk/messaging/azservicebus/sender_unit_test.go | Adds unit tests validating vendor-property behavior and user override. |
| sdk/messaging/azservicebus/internal/rpc_test.go | Updates test RPC sender implementation to satisfy the expanded sender interface. |
| sdk/messaging/azservicebus/internal/mock/mock_amqp.go | Regenerates/updates gomock types for the new Properties() method on senders. |
| sdk/messaging/azservicebus/internal/mock/emulation/mock_data_sender.go | Adds default Properties() expectation for mocked senders. |
| sdk/messaging/azservicebus/internal/amqpwrap/mock_amqp_test.go | Updates amqpwrap mocks to include Properties() for sender interfaces. |
| sdk/messaging/azservicebus/internal/amqpwrap/amqpwrap.go | Adds Properties() to AMQPSender and forwards it in AMQPSenderWrapper. |
| sdk/messaging/azservicebus/internal/amqp_test_utils.go | Updates FakeAMQPSender to implement Properties(). |
- Use type switch for numeric types (uint64, uint32, int64, int) instead of single uint64 assertion for vendor property value - Rename tests to match existing TestSenderNewMessageBatch_ pattern - Simplify test comments
j7nw4r
approved these changes
Apr 30, 2026
Contributor
Author
|
/azp run go - pullrequest |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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 Go SDK readsmax-message-size(viaMaxMessageSize()) for batch sizing inNewMessageBatch(), so batches up to 100 MB are accepted client-side and then rejected by the broker.Related: azure-service-bus#708
Fix
Read the
com.microsoft:max-message-batch-sizevendor property from the AMQP sender link attach frame, which correctly reports 256 KB (Standard) / 1 MB (Premium) independent of entity-levelmax-message-size. Fall back toMaxMessageSize()when the vendor property is absent.Changes
sender.go: Read vendor property fromProperties()inNewMessageBatch(); prefer it overMaxMessageSize()amqpwrap.go: AddProperties() map[string]anytoAMQPSenderinterface andAMQPSenderWrapper, matching the existing pattern onAMQPReceiverProperties()toMockAMQPSender,MockAMQPSenderCloser,FakeAMQPSender,rpcTester; add default expectation inmock_data_sender.gosender_unit_test.go: 3 new tests: vendor property overridesMaxMessageSize, fallback when absent, userMaxBytesoverrideCross-SDK alignment