Skip to content

BusOptions.Headers: headers stamped on every published message - #98

Merged
omarghatasheh merged 1 commit into
mainfrom
muhannad/static-headers
Oct 31, 2026
Merged

omarghatasheh merged 1 commit into
mainfrom
muhannad/static-headers

Conversation

@mmalkhatib

Copy link
Copy Markdown
Contributor

Adds BusOptions.Headers, an IDictionary<string, string> (case-insensitive) of headers put on every published message. It's for values that describe the publisher, not the message: for example which deployment sent it, so consumers or a shared broker can tell deployments apart without guessing from the exchange name.

services.AddBus(o => o.Headers["deployment"] = configuration["Deployment:Id"]);
  • Added last in BasicPublisher.Publish. A header the bus sets itself (contract, trace headers, user, correlation, source-node-id, Id) keeps its value on a name clash. Its Headers.Add calls can't throw on a duplicate either.
  • An empty value is left out.
  • Empty by default, so nothing changes for existing users.

Tests: new StaticHeaderTests (Testcontainers RabbitMQ) covers the configured header arriving, the bus's Id winning a clash, and an empty value omitted. The full suite passes: 19 integration, 1 unit. README: a short section under Publishing.

For values that describe the publisher rather than the message, such as which deployment sent it. Added last, so
a header the bus sets itself (contract, trace, user, Id...) is never replaced, and an empty value is left out.
Names compare case-insensitively.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: b0a13173-0a5a-4bf6-9b83-00964c7a99b8
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@omarghatasheh
omarghatasheh merged commit 6f1607b into main Oct 31, 2026
6 checks passed
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.

2 participants