Axanndar.Consumer
1.0.1
dotnet add package Axanndar.Consumer --version 1.0.1
NuGet\Install-Package Axanndar.Consumer -Version 1.0.1
<PackageReference Include="Axanndar.Consumer" Version="1.0.1" />
<PackageVersion Include="Axanndar.Consumer" Version="1.0.1" />
<PackageReference Include="Axanndar.Consumer" />
paket add Axanndar.Consumer --version 1.0.1
#r "nuget: Axanndar.Consumer, 1.0.1"
#:package Axanndar.Consumer@1.0.1
#addin nuget:?package=Axanndar.Consumer&version=1.0.1
#tool nuget:?package=Axanndar.Consumer&version=1.0.1
Axanndar.Consumer
This .NET library adds an abstraction layer over ActiveMQ Artemis, handling connection creation, consumer instantiation, and automatic re-creation in case of failures. It provides tools to easily implement new consumers by extending a base class (BaseConsumer), and facilitates dependency injection of consumers via configuration (appsettings.json) or code.
Create new Consumer
public class FooConsumer : BaseConsumer
{
public FooConsumer(Axanndar.Consumer.Models.ConsumerConfiguration consumerConfiguration, IArtemisClientConnectionFactory connectionFactory) : base(consumerConfiguration, connectionFactory)
{
}
public override async Task ReceiveMessage(Message message)
{
Console.WriteLine($"FooConsumer - Received message with ID: {message.MessageId}");
await Accept(message);
}
}
public class DummyConsumer : BaseConsumer
{
public DummyConsumer(Axanndar.Consumer.Models.ConsumerConfiguration consumerConfiguration, IArtemisClientConnectionFactory connectionFactory) : base(consumerConfiguration, connectionFactory)
{
}
public override async Task ReceiveMessage(Message message)
{
Console.WriteLine($"FooConsumer - Received message with ID: {message.MessageId}");
await Reject(message);
}
}
Service registration
appsettings.json
{
"Amqp": {
"FooConsumer": {
"RetryTime": 5000,
"IsActive": true,
"Address": "my-address",
"Queue": "my-queue",
"RoutingType": 0,
"Credit": 200,
"Durable": false,
"FilterExpression": "",
"NoLocalFilter": false,
"Shared": false,
"Endpoints": [
{
"Host": "localhost",
"Port": 5672,
"User": "user",
"Password": "password"
}
]
}
}
}
You can register the Consumer service simply with dependency injection:
// Via options configuration
IConfiguration config = ...;
services
.AddConsumerBackgroundService<FooConsumer>("FooConsumer", config);
// Via code configuration
services
.AddConsumerBackgroundService<DummyConsumer>(new Axanndar.Consumer.Models.ConsumerConfiguration
{
IdEndpoint = "DummyConsumer",
Address = "DummyConsumer.Address",
Queue = "DummyConsumer.Queue",
Endpoints = new List<Axanndar.Consumer.Models.ConsumerConfigurationEndpoint> {
new Axanndar.Consumer.Models.ConsumerConfigurationEndpoint
{
Host = "localhost",
Port = 61616,
Password = "password",
User = "user"
}
},
IsActive = true,
RetryTime = 5,
RoutingType = (int)RoutingType.Anycast,
});
Licensee
Repository source code is available under MIT License, see license in the source.
Contributing
Thank you for considering to help out with the source code! If you'd like to contribute, please fork, fix, commit and send a pull request for the maintainers to review and merge into the main code base.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- AMQPNetLite (>= 2.5.1)
- AMQPNetLite.Core (>= 2.5.1)
- AMQPNetLite.WebSockets (>= 2.5.1)
- ArtemisNetClient (>= 3.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Nito.AsyncEx.Coordination (>= 5.1.2)
- Nito.Collections.Deque (>= 1.2.1)
- Nito.Disposables (>= 2.5.0)
- Polly (>= 8.6.4)
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.1 | 359 | 11/26/2025 |