Publish events from a .NET microservice to RabbitMQ or Kafka without losing messages if the queue goes down mid-transaction.
Subscribe to events from other services by adding a [CapSubscribe] attribute to a method and letting CAP route incoming messages automatically.
Monitor message delivery and trigger retries from the built-in web dashboard when a message fails to reach its consumer.
Add distributed tracing to your message flows using the built-in OpenTelemetry integration.
NuGet install is simple but requires a running message broker (RabbitMQ, Kafka, etc.) and a supported database to be already in place.
CAP is an open-source .NET library that helps microservices communicate with each other reliably when they use a shared database. The core problem it solves is this: if your service publishes a message to a queue like RabbitMQ or Kafka, and then the queue goes down before the message is delivered, or your database transaction fails after the message was already sent, data can end up in an inconsistent state. CAP prevents that by storing the message in a local table inside your existing database first, and only sending it to the queue once the database transaction has committed successfully. This approach is called the Outbox Pattern. The library works as a plugin inside a .NET application. You install the main package from NuGet, then add one or more transport packages for the message queue you want to use, and one storage package for the database you are already using. Once configured in your startup code, you can inject an ICapPublisher service into your controllers or services and call Publish or PublishDelay to send events. On the receiving end, you add a CapSubscribe attribute to a method and the library routes incoming messages to it automatically. Supported transport options include RabbitMQ, Kafka, Azure Service Bus, Amazon SQS, NATS, Redis Streams, and Pulsar. Supported storage options include SQL Server, MySQL, PostgreSQL, and MongoDB. This lets the library fit into most existing .NET infrastructure without requiring new services. Additional features include a built-in web dashboard for monitoring message status and triggering retries, OpenTelemetry instrumentation for distributed tracing, backpressure management to prevent memory overload under high load, and support for delayed message delivery without relying on queue-side timers. The library is MIT licensed and part of the .NET Core Community organization.
← dotnetcore on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.