VOOZH about

URL: https://www.nuget.org/packages/Moclawr.DotNetCore.CAP/

⇱ NuGet Gallery | Moclawr.DotNetCore.CAP 2.1.0




👁 Image
Moclawr.DotNetCore.CAP 2.1.0

dotnet add package Moclawr.DotNetCore.CAP --version 2.1.0
 
 
NuGet\Install-Package Moclawr.DotNetCore.CAP -Version 2.1.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Moclawr.DotNetCore.CAP" Version="2.1.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Moclawr.DotNetCore.CAP" Version="2.1.0" />
 
Directory.Packages.props
<PackageReference Include="Moclawr.DotNetCore.CAP" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Moclawr.DotNetCore.CAP --version 2.1.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Moclawr.DotNetCore.CAP, 2.1.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Moclawr.DotNetCore.CAP@2.1.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Moclawr.DotNetCore.CAP&version=2.1.0
 
Install as a Cake Addin
#tool nuget:?package=Moclawr.DotNetCore.CAP&version=2.1.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Moclawr.DotNetCore.CAP

👁 NuGet

Overview

Moclawr.DotNetCore.CAP provides an enhanced implementation of the DotNetCore.CAP library, simplifying the integration of event-based microservices and distributed transaction processing across multiple message queuing platforms and databases. It offers a consistent configuration interface for various message brokers including RabbitMQ, Kafka, Redis Streams, and Azure Service Bus.

Features

  • Unified Configuration: Standardized configuration approach for all supported message brokers
  • Multiple Message Broker Support:
    • RabbitMQ
    • Kafka
    • Redis Streams
    • Azure Service Bus
    • Pulsar
  • Database Storage Options:
    • SQL Server
    • MySQL
    • PostgreSQL
    • MongoDB
    • In-Memory (for development/testing)
  • Built-in Dashboard: Monitor message publication and consumption through a web interface
  • Distributed Transaction Support: Ensures data consistency across services
  • Auto-configuration: Simplified setup with minimal code

Installation

Install the package via NuGet Package Manager:

dotnet add package Moclawr.DotNetCore.CAP

Usage

Basic Configuration

In your Program.cs or Startup.cs, configure the DotnetCap services:

using DotnetCap;

// Register DotnetCap services
builder.Services.AddDotnetCap(builder.Configuration);

Configuration in appsettings.json

{
 "DotnetCap": {
 "DbProvider": "PostgreSQL",
 "ConnectionString": "Host=localhost;Port=5432;Database=capdb;Username=postgres;Password=password",
 "UseDashboard": true,
 "DashboardPath": "/cap-dashboard",
 "EnabledDashboardAuth": false,
 "DashboardAuthUser": "admin",
 "DashboardAuthPassword": "admin"
 }
}

Configuring RabbitMQ

// Register RabbitMQ specific configuration
builder.Services.AddRabbitMq(builder.Configuration);

Configuration in appsettings.json:

{
 "DotnetCap": {
 "RabbitMQOptions": {
 "HostName": "localhost",
 "Port": 5672,
 "UserName": "guest",
 "Password": "guest",
 "VirtualHost": "/",
 "ExchangeName": "cap.exchange",
 "PublishConfirms": true,
 "QueueArguments": {
 "QueueMode": "lazy",
 "MessageTTL": 3600000,
 "QueueType": "classic"
 },
 "QueueOptions": {
 "Durable": true,
 "Exclusive": false,
 "AutoDelete": false
 }
 }
 }
}

Configuring Kafka

// Register Kafka specific configuration
builder.Services.AddKafka(builder.Configuration);

Configuration in appsettings.json:

{
 "DotnetCap": {
 "KafkaOptions": {
 "BootstrapServers": ["localhost:9092"],
 "ConnectionPoolSize": 10,
 "GroupId": "cap-consumer-group",
 "ClientId": "cap-client",
 "SecurityProtocol": "PLAINTEXT",
 "SaslMechanism": "PLAIN",
 "SaslUsername": "",
 "SaslPassword": "",
 "MainConfig": {
 "auto.offset.reset": "earliest",
 "enable.auto.commit": "false"
 }
 }
 }
}

Publishing Messages

using DotNetCore.CAP;

public class OrderService
{
 private readonly ICapPublisher _capPublisher;

 public OrderService(ICapPublisher capPublisher)
 {
 _capPublisher = capPublisher;
 }

 public async Task CreateOrderAsync(Order order)
 {
 // Business logic...
 
 // Publish the order created event
 await _capPublisher.PublishAsync("order.created", order);
 }
}

Subscribing to Messages

using DotNetCore.CAP;

public class OrderConsumer : ICapSubscribe
{
 [CapSubscribe("order.created")]
 public async Task HandleOrderCreatedAsync(Order order)
 {
 // Process the order...
 await Task.CompletedTask;
 }
}

Integration with Other Moclawr Packages

This package works seamlessly with other packages in the Moclawr ecosystem:

  • Moclawr.Core: Provides configuration models and utilities used by DotnetCap
  • Moclawr.Shared: Uses standardized response models for message handling
  • Moclawr.Host: Perfect companion for building complete API solutions with event-driven architecture
  • Moclawr.EfCore: Integrates with Entity Framework Core for transactional messaging and outbox patterns
  • Moclawr.MongoDb: Supports MongoDB integration for document-based event storage
  • Moclawr.MinimalAPI: Use with endpoint handlers for publishing events in API operations
  • Moclawr.Services.External: Trigger external notifications through event-driven messaging

Requirements

  • .NET 9.0 or higher
  • DotNetCore.CAP 8.3.4 or higher
  • One or more of the supported message brokers (RabbitMQ, Kafka, Redis, etc.)

License

This package is licensed under the MIT License.

Product Versions Compatible and additional computed target framework versions.
.NET net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 402 5/28/2025
2.0.0 187 5/24/2025
1.0.3 175 5/24/2025
1.0.2 218 5/22/2025
1.0.1 227 5/21/2025
1.0.0 336 5/15/2025

Added improved XML documentation and bug fixes.