explaingit

dotnetcore/cap

Analysis updated 2026-06-22

7,084C#Audience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

A .NET library that makes microservice messaging reliable by storing outgoing messages in your database before sending them to a queue, so no message is lost if the queue or your service crashes, implementing the Outbox Pattern.

Mindmap

mindmap
  root((CAP))
    What it solves
      Lost messages
      Failed transactions
      Distributed consistency
    Transport options
      RabbitMQ
      Kafka
      Azure Service Bus
      Amazon SQS
    Storage options
      SQL Server
      PostgreSQL
      MySQL
      MongoDB
    Extra features
      Web dashboard
      OpenTelemetry tracing
      Delayed messages
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Publish events from a .NET microservice to RabbitMQ or Kafka without losing messages if the queue goes down mid-transaction.

USE CASE 2

Subscribe to events from other services by adding a [CapSubscribe] attribute to a method and letting CAP route incoming messages automatically.

USE CASE 3

Monitor message delivery and trigger retries from the built-in web dashboard when a message fails to reach its consumer.

USE CASE 4

Add distributed tracing to your message flows using the built-in OpenTelemetry integration.

What is it built with?

C#.NETRabbitMQKafkaPostgreSQLSQL ServerMySQLMongoDB

How does it compare?

dotnetcore/capnancyfx/nancylouthy/language-ext
Stars7,0847,1067,048
LanguageC#C#C#
Setup difficultymoderatemoderateeasy
Complexity3/53/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 1h+

NuGet install is simple but requires a running message broker (RabbitMQ, Kafka, etc.) and a supported database to be already in place.

MIT licensed, use freely for any purpose including commercial projects, with no obligation to share your code.

In plain English

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.

Copy-paste prompts

Prompt 1
I want to add CAP to my ASP.NET Core service to publish events to RabbitMQ with the Outbox Pattern. Walk me through the NuGet packages and wiring it up in Program.cs.
Prompt 2
How do I use the [CapSubscribe] attribute in CAP to handle incoming events from another microservice in my .NET app?
Prompt 3
My CAP messages are failing to deliver. How do I use the built-in dashboard to find which messages failed and trigger a retry?
Prompt 4
I want to use CAP with PostgreSQL for storage and Kafka for transport. Which NuGet packages do I install and how do I configure them in startup?
Prompt 5
How does CAP prevent duplicate message processing if my subscriber crashes partway through handling a message?

Frequently asked questions

What is cap?

A .NET library that makes microservice messaging reliable by storing outgoing messages in your database before sending them to a queue, so no message is lost if the queue or your service crashes, implementing the Outbox Pattern.

What language is cap written in?

Mainly C#. The stack also includes C#, .NET, RabbitMQ.

What license does cap use?

MIT licensed, use freely for any purpose including commercial projects, with no obligation to share your code.

How hard is cap to set up?

Setup difficulty is rated moderate, with roughly 1h+ to a first successful run.

Who is cap for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.