Axanndar.Consumer 1.0.1

dotnet add package Axanndar.Consumer --version 1.0.1
                    
NuGet\Install-Package Axanndar.Consumer -Version 1.0.1
                    
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="Axanndar.Consumer" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Axanndar.Consumer" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Axanndar.Consumer" />
                    
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 Axanndar.Consumer --version 1.0.1
                    
#r "nuget: Axanndar.Consumer, 1.0.1"
                    
#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 Axanndar.Consumer@1.0.1
                    
#: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=Axanndar.Consumer&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Axanndar.Consumer&version=1.0.1
                    
Install as a Cake Tool

License: MIT Nuget NuGet Downloads issues - Axanndar.Consumer

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 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. 
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
1.0.1 359 11/26/2025