![]() |
VOOZH | about |
dotnet add package Moclawr.DotNetCore.CAP --version 2.1.0
NuGet\Install-Package Moclawr.DotNetCore.CAP -Version 2.1.0
<PackageReference Include="Moclawr.DotNetCore.CAP" Version="2.1.0" />
<PackageVersion Include="Moclawr.DotNetCore.CAP" Version="2.1.0" />Directory.Packages.props
<PackageReference Include="Moclawr.DotNetCore.CAP" />Project file
paket add Moclawr.DotNetCore.CAP --version 2.1.0
#r "nuget: Moclawr.DotNetCore.CAP, 2.1.0"
#:package Moclawr.DotNetCore.CAP@2.1.0
#addin nuget:?package=Moclawr.DotNetCore.CAP&version=2.1.0Install as a Cake Addin
#tool nuget:?package=Moclawr.DotNetCore.CAP&version=2.1.0Install as a Cake Tool
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.
Install the package via NuGet Package Manager:
dotnet add package Moclawr.DotNetCore.CAP
In your Program.cs or Startup.cs, configure the DotnetCap services:
using DotnetCap;
// Register DotnetCap services
builder.Services.AddDotnetCap(builder.Configuration);
{
"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"
}
}
// 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
}
}
}
}
// 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"
}
}
}
}
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);
}
}
using DotNetCore.CAP;
public class OrderConsumer : ICapSubscribe
{
[CapSubscribe("order.created")]
public async Task HandleOrderCreatedAsync(Order order)
{
// Process the order...
await Task.CompletedTask;
}
}
This package works seamlessly with other packages in the Moclawr ecosystem:
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. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
Added improved XML documentation and bug fixes.