Skip to content
Back to skills

Bus Kafka Dotnet

ASecurity

How the services use the Kafka transport of the JorgeCostaMacia.Bus family — the decisions on top of the library (see `bus-dotnet` for what every transport shares). Use when configuring a Kafka consumer, producer or admin (the Bus:Consumer, Bus:Producer and Bus:Admin settings, AutoOffsetReset, BootstrapServers, SASL credentials, the security protocol), naming or creating topics, choosing partitions, touching consumer groups or their offsets, thinking about message keys or ordering on Kafka, o...

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentsgogitsecurity

Works with

  • cli

Security analysis

A100/100

Scanned December 4, 2026

npx -y skills add JorgeCostaMacia/code-harness --skill bus-kafka-dotnet --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Bus Kafka Dotnet?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Bus Kafka Dotnet
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jorgecostamacia-bus-kafka-dotnet-code-harness/badge)](https://www.skillsdirectory.com/skills/jorgecostamacia-bus-kafka-dotnet-code-harness)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: bus-kafka-dotnet
description: >-
  How the services use the Kafka transport of the JorgeCostaMacia.Bus family
  — the decisions on top of the library (see `bus-dotnet` for what every
  transport shares). Use when configuring a Kafka consumer, producer or
  admin (the Bus:Consumer, Bus:Producer and Bus:Admin settings,
  AutoOffsetReset, BootstrapServers, SASL credentials, the security
  protocol), naming or creating topics, choosing partitions, touching
  consumer groups or their offsets, thinking about message keys or ordering
  on Kafka, or reading and replaying parked messages. It encodes: the topic
  is the route with the contracts' major, partitions declared per service in
  the admin map, no message key on purpose, the consumer group as a stable
  contract named after the handler, where a new group starts, parked
  messages in .error and .fault, one broker user per service, the security
  protocol from each environment's configuration (SaslSsl in production),
  and a stop to ask before anything moves topics, groups or offsets.
---

# The bus on Kafka — how we use it

The decisions the services make on top of `JorgeCostaMacia.Bus.Kafka`. The README in [bus-kafka-dotnet](https://github.com/JorgeCostaMacia/bus-kafka-dotnet) tells how the library works inside: its error handling, its throttling defaults, its health checks. This skill tells what a service decides.

## Topics

- **A topic is a route**: `<service>.v{major}.<module>.<action>.{command|event}`, the module in kebab case. The major is read from the contracts assembly. The contracts package's own `<Module>BusPresentationContext` (namespace `<Service>.Contracts.<Module>.Presentation`, not the service's type of the same name) builds the base route with `typeof(<Module>BusPresentationContext).Assembly.GetName().Version?.Major`. So it is the contracts package's major, never the service's, and moves only with it.
- **The admin map, in the contracts package, creates the topics** with their partition count. The producer map registers the same messages without a count. The host composes both maps: the service's own first, then those of every consumed service.
- **The partition count only applies when the admin creates the topic.** The admin worker is idempotent: it does not touch a topic that already exists. So a new count in the contracts changes nothing on the broker. A new count ships as a **new contracts major**: the routes carry the major, so the admin creates new topics with the new count. Their consumer groups are new too (the group is the route). By default they start from the beginning of the new topics (`AutoOffsetReset` `Earliest`), so no message sent there is lost; a service can choose otherwise (see below). The messages that nobody consumed on the old major's topics stay there unread. Let the old consumers drain them before the move, or accept the loss (a message that a scheduled job sends again is no loss).
- **Partitions are the unit of parallelism**, declared per service as two literals — events and commands. A command that fans out into many (one per page) needs as many command partitions as the consumers that share them. A service whose commands don't fan out can keep fewer.
- **Stop and ask before a change that moves topics or groups.** A new partition count, a new contracts major, or a renamed route (a module's, a handler's, a subscriber's) creates new topics or new consumer groups. Messages left on the old topics stay unread, and a new group at `Earliest` replays what its topic holds. Tell the person what the change moves and let them decide; never make it as a side effect of another change.
- **An agent never acts on the broker itself.** It never replays a parked message, never resets or moves a consumer group's offsets, and never creates, deletes or repartitions a topic. It gives the person the command, and the person runs it.

## No message key

The producer sends messages **without a key**: two messages for one aggregate can land on different partitions, and two consumers can handle them at once. That is deliberate, because the services' ids are too heterogeneous to key by. The consumer defends the order instead: version in the data, strict guard, optimistic concurrency (see `messaging`). Don't add a key to "fix" ordering.

## Consumer groups

- **The group id is the handler's or subscriber's route** (`{command route}.handler`, `{…}.on.{event route}.subscriber`). It is a **stable contract**: Kafka keeps the group's offsets under it. A renamed route starts a new group from scratch and abandons the position of the old group.
- Each handler and subscriber is its own group. So every service, and every subscriber in a service, receives every event of a topic it subscribes to.
- **Where a new group starts is a per-service choice.** A group has no stored offset on its first start, after a renamed route, on a new major, or when its offsets expired while the group did not run. The library starts such a group at `Earliest`, the at-least-once bias. The group replays what the topic still holds and does not skip what producers published before it joined. If the handling of a service reaches people (an email, a report), the service sets `Bus:Consumer:AutoOffsetReset` to `Latest` instead, because a replay sends everything again. The price: no message published before the group exists reaches it. So on a new major, that service deploys before its producers move. A group with offsets keeps them either way. The setting only acts on a new group, and you do not have to recreate a group to apply it.

## Parked messages

The bus does not retry a message after a `ValidationException` or after the last step of the ladder. That message goes to **`<topic>.error`**, with the exception and the failing group. A message that the consumer cannot even read goes to `<topic>.fault`. Both are topics, so a parked message is never lost: you can read it there, and the person can replay it from there. An agent reads a parked message and says why it failed; to replay it, it gives the person the command.

## Credentials

- `Bus:Producer`, `Bus:Consumer` and `Bus:Admin` each carry `BootstrapServers`, `SaslUsername`, `SaslPassword`. The passwords are secrets — user secrets locally, the deployment's secret in production — never in `appsettings*.json`.
- **One broker user per service**: a service never connects with another's credentials, so ACLs and the broker's logs name the real client.
- **The security protocol comes from each environment's configuration** (`SecurityProtocol` in `Bus:Producer`, `Bus:Consumer` and `Bus:Admin`), never from code. Production uses SASL over TLS (`SaslSsl`, the library's default when the key is absent), and a development or test broker may use `Plaintext`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.