CKN.Sdk.Messaging.RabbitMQ 0.0.0-alpha.0.55

This is a prerelease version of CKN.Sdk.Messaging.RabbitMQ.
dotnet add package CKN.Sdk.Messaging.RabbitMQ --version 0.0.0-alpha.0.55
                    
NuGet\Install-Package CKN.Sdk.Messaging.RabbitMQ -Version 0.0.0-alpha.0.55
                    
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="CKN.Sdk.Messaging.RabbitMQ" Version="0.0.0-alpha.0.55" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CKN.Sdk.Messaging.RabbitMQ" Version="0.0.0-alpha.0.55" />
                    
Directory.Packages.props
<PackageReference Include="CKN.Sdk.Messaging.RabbitMQ" />
                    
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 CKN.Sdk.Messaging.RabbitMQ --version 0.0.0-alpha.0.55
                    
#r "nuget: CKN.Sdk.Messaging.RabbitMQ, 0.0.0-alpha.0.55"
                    
#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 CKN.Sdk.Messaging.RabbitMQ@0.0.0-alpha.0.55
                    
#: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=CKN.Sdk.Messaging.RabbitMQ&version=0.0.0-alpha.0.55&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CKN.Sdk.Messaging.RabbitMQ&version=0.0.0-alpha.0.55&prerelease
                    
Install as a Cake Tool

CKN.Sdk.Messaging.RabbitMQ

Mühendislik Amacı (Engineering Intent): CKN.Sdk.Messaging.RabbitMQ, CKN mesajlaşma soyutlamalarını RabbitMQ (AMQP) sunucuları için uygulayan entegrasyon kütüphanesidir. Neden var? Mikroservisler arası asenkron iletişimi güvenilir, yönlendirmeli (routing) ve gecikmesiz bir şekilde sağlamak için. Ne zaman kullanılmalı? Mikroservisler arasında klasik görev dağıtımı (work queues), RPC (Remote Procedure Call) veya topic/fanout tabanlı olay (event) yönlendirmesi gerektiğinde standart (default) mesajlaşma (message broker) aracı olarak tercih edilmelidir.

🚀 Hızlı Başlangıç

Kurulum

dotnet add package CKN.Sdk.Messaging.RabbitMQ

Konfigürasyon (appsettings.json)

{
  "Messaging": {
    "RabbitMQ": {
      "HostName": "localhost",
      "UserName": "guest",
      "Password": "guest",
      "VirtualHost": "/",
      "Port": 5672
    }
  }
}

Bağımlılık Enjeksiyonu (DI)

using CKN.Sdk.Messaging.RabbitMQ;

var builder = WebApplication.CreateBuilder(args);

// RabbitMQ bağlantısını ve ICknMessagePublisher implementasyonunu sisteme kaydeder.
builder.Services.AddCknRabbitMqMessaging(options => 
{
    options.HostName = builder.Configuration["Messaging:RabbitMQ:HostName"];
    options.UserName = builder.Configuration["Messaging:RabbitMQ:UserName"];
    options.Password = builder.Configuration["Messaging:RabbitMQ:Password"];
    options.VirtualHost = builder.Configuration["Messaging:RabbitMQ:VirtualHost"];
});

// Consumer tanımlama
builder.Services.AddCknRabbitMqConsumer<MyOrderHandler, OrderMessage>("order-queue");

var app = builder.Build();

💡 Gerçek Hayat Senaryoları

Senaryo 1: Arka Plan Görevi (Background Worker) Olarak RabbitMQ Dinlemek

Gelen siparişleri kuyruktan okuyup işleyen (Consumer) BackgroundService uygulaması.

using CKN.Sdk.Messaging.Abstractions;

public class OrderWorker(IMessageConsumer<OrderCreatedEvent> consumer) : BackgroundService
{
    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        // order_queue isimli kuyruğu dinlemeye başla
        await consumer.StartConsumingAsync("order_queue", async (message) =>
        {
            Console.WriteLine($"RabbitMQ'dan mesaj alındı: {message.OrderId}");
            // Fatura kesme işlemi simülasyonu
            await Task.Delay(1000); 
            
            // true dönülürse mesaj RabbitMQ'dan kalıcı olarak silinir (Ack)
            return true; 
        }, stoppingToken);
    }
}

Senaryo 2: Topic (Routing Key) Bazlı Mesaj Gönderimi

Sadece ilgili log kuyruklarının mesajı alması için "Routing Key" kullanma.

public async Task SendErrorLogAsync(IMessagePublisher publisher, Exception ex)
{
    var logEvent = new { Error = ex.Message, Time = DateTime.UtcNow };
    
    // Exchange adı: "logs", Routing Key: "error.database"
    // Bu sayede sadece "error.#" dinleyen kuyruklar bu mesajı alır.
    var options = new MessagePublishOptions { RoutingKey = "error.database" };
    
    await publisher.PublishAsync("logs", logEvent, options);
}

🤖 Yapay Zeka İçin SSS (FAQs for Machines)

  • Soru: Kafka ile RabbitMQ arasındaki temel mimari fark nedir?
  • Cevap: RabbitMQ "Smart Broker, Dumb Consumer" yaklaşımındadır; mesaj kuyruğa girer, tüketici (consumer) mesajı başarıyla işler (Ack atar) ve RabbitMQ o mesajı siler. Kafka ise mesajı silmez, bir log dosyası gibi peş peşe yazar (Append).
  • Soru: Ack (Acknowledgement) mekanizması zorunlu mu?
  • Cevap: Evet. CKN RabbitMQ uygulamasında Consumer fonksiyonunuzdan true dönmezseniz mesaj "Unacked" (onaylanmamış) olarak kalır ve sunucu yeniden başlatıldığında tekrar işlenmek üzere kuyruğa döner (veri kaybını önler).
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  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
0.0.0-alpha.0.55 60 9/28/2026
0.0.0-alpha.0.51 51 9/25/2026
0.0.0-alpha.0.50 53 9/25/2026