CodeQuartz.Portal
1.0.0
dotnet add package CodeQuartz.Portal --version 1.0.0
NuGet\Install-Package CodeQuartz.Portal -Version 1.0.0
<PackageReference Include="CodeQuartz.Portal" Version="1.0.0" />
<PackageVersion Include="CodeQuartz.Portal" Version="1.0.0" />
<PackageReference Include="CodeQuartz.Portal" />
paket add CodeQuartz.Portal --version 1.0.0
#r "nuget: CodeQuartz.Portal, 1.0.0"
#:package CodeQuartz.Portal@1.0.0
#addin nuget:?package=CodeQuartz.Portal&version=1.0.0
#tool nuget:?package=CodeQuartz.Portal&version=1.0.0
CodeQuartz.Portal.RabbitMQ
A simple and extensible RabbitMQ integration library for .NET applications.
This library provides a lightweight abstraction over RabbitMQ to simplify message publishing and consumption using common patterns like dependency injection (ISender
, IReceiver
), fluent configuration, and support for multiple queues.
✨ Features
- 📤 Publish messages with automatic JSON serialization.
- 📥 Consume messages asynchronously with built-in ACK/NACK control.
- ⚙️ Easy integration with
IServiceCollection
and dependency injection. - 🔄 Supports durable queues and custom exchange/queue settings.
- 🔐 Built-in configuration for multiple queues and secure connection options.
🚀 Installation
Install via NuGet:
dotnet add package CodeQuartz.Portal
🧩 Configuration
1. Register the sender
services.AddPortalSender(options =>
{
options.Exchange = "my-exchange";
options.ExchangeType = "direct";
options.Queues = ["queue-a", "queue-b"];
options.HostConfig = new QueueConfiguration
{
Host = "localhost",
Port = 5672,
Username = "guest",
Password = "guest"
};
});
📤 Sending Messages
public class HelloCommand
{
public required string Name { get; set; }
}
public class QueueService
{
private readonly ISender _sender;
public QueueService(ISender sender)
{
_sender = sender;
}
public async Task SendMessage()
{
var command = new HelloCommand { Name = "Test" };
await _sender.Send("queue-a", command);
}
}
📥 Listening for Messages
var portal = new PortalBuilder(new QueueOptions
{
Exchange = "my-exchange",
Queues = ["queue-a"],
HostConfig = new QueueConfiguration
{
Host = "localhost",
Port = 5672,
Username = "guest",
Password = "guest"
}
}).UsePortal().GetAwaiter().GetResult();
var receiver = new PortalReceiver(portal, "my-exchange");
await receiver.Listen<HelloCommand>("queue-a", autoAck: false, async command =>
{
Console.WriteLine($"Received: {command.Name}");
return true;
});
receiver.Run();
🛠️ Components
PortalSender
- Publishes messages using an IChannel.
- JSON-serializes objects before publishing.
- Injectable via ISender.
PortalReceiver
- Listens to a specific queue.
- Deserializes messages and handles acknowledgment based on the callback's result.
PortalBuilder
- Initializes the RabbitMQ connection and channel.
- Declares exchanges and queues, and binds queues to the exchange.
✅ Requirements
- .NET 8 or later
- Running RabbitMQ Server
📄 License
This project is licensed under the MIT License.
🤝 Contributing
Contributions are welcome! Feel free to open issues or pull requests with improvements, bug fixes, or suggestions.
🧠 Author
Developed with ❤️ by Daniel Lopes
Product | Versions 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 was computed. 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 was computed. 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.6)
- Microsoft.Extensions.Options (>= 8.0.2)
- Newtonsoft.Json (>= 13.0.3)
- RabbitMQ.Client (>= 7.1.2)
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 |
---|---|---|
1.0.0 | 141 | 6/14/2025 |