Skip to content

fix!: Send Service Bus events as single objects instead of arrays#261

Merged
pm7y merged 5 commits intomasterfrom
copilot/make-servicebus-message-configurable
Feb 18, 2026
Merged

fix!: Send Service Bus events as single objects instead of arrays#261
pm7y merged 5 commits intomasterfrom
copilot/make-servicebus-message-configurable

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

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 uses SerializeSingle() for both delivery paths
  • IEventSchemaFormatter: Added SerializeSingle() method for non-array serialization
  • CloudEventSchemaFormatter / EventGridSchemaFormatter: Implemented SerializeSingle()
  • commit-msg hook: Updated to support ! breaking change indicator per Conventional Commits spec
  • Wiki: Updated Topics.md to document the delivery format difference between HTTP and Service Bus subscribers
  • Tests: Added tests verifying single-object format for both schemas, and that Serialize() still returns arrays for other subscriber types (HTTP, StorageQueue, EventHub)

Before / After

Subscriber Type Before After
Service Bus [{"id":"...","type":"..."}] {"id":"...","type":"..."}
HTTP [{"id":"...","type":"..."}] [{"id":"...","type":"..."}] (unchanged)

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
Copilot AI requested a review from pm7y February 13, 2026 00:16
@pm7y pm7y force-pushed the copilot/make-servicebus-message-configurable branch from 7aa7aa9 to 9ff2472 Compare February 18, 2026 10:27
Copilot AI and others added 5 commits February 18, 2026 20:27
- 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>
@pm7y pm7y force-pushed the copilot/make-servicebus-message-configurable branch from 9ff2472 to b9d0156 Compare February 18, 2026 10:28
@pm7y pm7y marked this pull request as ready for review February 18, 2026 10:36
Copilot AI review requested due to automatic review settings February 18, 2026 10:36
@pm7y pm7y changed the title feat: Add configurable single event delivery for ServiceBus subscribers fix!: Send Service Bus events as single objects instead of arrays Feb 18, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pm7y pm7y merged commit d033b19 into master Feb 18, 2026
15 of 16 checks passed
@pm7y pm7y deleted the copilot/make-servicebus-message-configurable branch February 18, 2026 10:39
@github-actions github-actions bot mentioned this pull request Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: EventGrid to ServiceBus as SingleEvent

2 participants

Comments