fix!: Send Service Bus events as single objects instead of arrays#261
Merged
fix!: Send Service Bus events as single objects instead of arrays#261
Conversation
Copilot
AI
changed the title
[WIP] Update configuration for ServiceBus single event messages
feat: Add configurable single event delivery for ServiceBus subscribers
Feb 13, 2026
7aa7aa9 to
9ff2472
Compare
- Add SerializeSingle method to IEventSchemaFormatter to serialize single events without array wrapper - Implement SerializeSingle in CloudEventSchemaFormatter and EventGridSchemaFormatter - Add singleEventDelivery property to ServiceBusSubscriberSettings - Update ServiceBusEventDeliveryService to use single event serialization when configured - Add unit tests for single event serialization Co-authored-by: pm7y <3075792+pm7y@users.noreply.github.com>
Address code review feedback by adding test for SingleEventDelivery = false Co-authored-by: pm7y <3075792+pm7y@users.noreply.github.com>
# Conflicts: # src/Directory.Packages.props
Service Bus delivery now always serializes events as single JSON objects without array wrapping, matching Azure Event Grid's actual behavior. Previously events were wrapped in a single-element array which forced consumers to add unnecessary array-handling logic. Removes the singleEventDelivery configuration option in favour of always using the correct Azure behavior. Also updates the commit-msg hook to support the ! breaking change indicator per the Conventional Commits spec. BREAKING CHANGE: Service Bus message bodies are now single JSON objects instead of single-element arrays. Consumers that parse the array format will need to be updated. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9ff2472 to
b9d0156
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds configurable single event delivery for ServiceBus subscribers to match Azure EventGrid's actual behavior. Previously, the simulator always wrapped events in arrays, requiring workarounds in event parsing logic.
Changes:
- Added
SerializeSingle()method to formatters for non-array event serialization - Modified ServiceBus delivery to always use single event format (matching Azure behavior)
- Updated dependency versions (Meziantou.Analyzer, coverlet.collector)
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| wiki | Updated subproject commit reference |
| src/Directory.Packages.props | Bumped analyzer and test coverage tool versions |
| src/AzureEventGridSimulator/Domain/Services/IEventSchemaFormatter.cs | Added SerializeSingle() interface method |
| src/AzureEventGridSimulator/Domain/Services/EventGridSchemaFormatter.cs | Implemented SerializeSingle() without array wrapper |
| src/AzureEventGridSimulator/Domain/Services/Delivery/ServiceBusEventDeliveryService.cs | Changed to use SerializeSingle() instead of Serialize() |
| src/AzureEventGridSimulator/Domain/Services/CloudEventSchemaFormatter.cs | Implemented SerializeSingle() without array wrapper |
| src/AzureEventGridSimulator.Tests/UnitTests/Subscribers/Delivery/ServiceBusEventDeliveryServiceTests.cs | Added tests for single event serialization |
| .githooks/commit-msg | Enhanced commit message validation to support breaking change indicator |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/AzureEventGridSimulator/Domain/Services/Delivery/ServiceBusEventDeliveryService.cs
Show resolved
Hide resolved
src/AzureEventGridSimulator/Domain/Services/Delivery/ServiceBusEventDeliveryService.cs
Show resolved
Hide resolved
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.
Summary
Azure Event Grid delivers events to Service Bus as single JSON objects, not wrapped in arrays. The simulator previously always wrapped events in a single-element array (
[{...}]), forcing consumers to add unnecessary array-handling logic that wouldn't be needed against real Azure.This PR fixes Service Bus delivery to always use single event format, matching Azure's actual behavior.
BREAKING CHANGE: Service Bus message bodies are now single JSON objects (
{...}) instead of single-element arrays ([{...}]). Consumers that parse the array format will need to be updated.Changes
ServiceBusEventDeliveryService: Always usesSerializeSingle()for both delivery pathsIEventSchemaFormatter: AddedSerializeSingle()method for non-array serializationCloudEventSchemaFormatter/EventGridSchemaFormatter: ImplementedSerializeSingle()commit-msghook: Updated to support!breaking change indicator per Conventional Commits specTopics.mdto document the delivery format difference between HTTP and Service Bus subscribersSerialize()still returns arrays for other subscriber types (HTTP, StorageQueue, EventHub)Before / After
[{"id":"...","type":"..."}]{"id":"...","type":"..."}[{"id":"...","type":"..."}][{"id":"...","type":"..."}](unchanged)