KubeMQ
Integrations.NET Aspire

.NET Aspire

Provision KubeMQ and configure IKubeMQClient in .NET Aspire apps with health checks, OpenTelemetry, and keyed DI.

The KubeMQ .NET Aspire integration wires the KubeMQ message broker into the .NET Aspire application model. It follows the standard Aspire two-package model: KubeMQ.Aspire.Hosting provisions a KubeMQ container in your AppHost, and KubeMQ.Aspire.Client configures an IKubeMQClient in each consuming service — complete with health checks, OpenTelemetry, and keyed dependency injection. The client is a native gRPC SDK client that connects to the broker on port 50000; there is no connector to enable.

New to the idea? See what is an integration for how SDK-level integrations differ from server-side connectors.

Why KubeMQ + .NET Aspire?

  • Container auto-provisioningAddKubeMQ("messaging") in the AppHost runs a KubeMQ broker container with the gRPC, REST, and Dashboard endpoints already mapped
  • Zero-config connection stringsWithReference(messaging) injects the broker address into each service as an Aspire connection string; AddKubeMQClient("messaging") reads it back automatically, so no host or port is hard-coded
  • Built-in health checks — readiness and liveness checks are registered out of the box with ready and live tags, surfacing the SDK's connection state to the Aspire dashboard and Kubernetes probes
  • OpenTelemetry on by default — the SDK's KubeMQ.Sdk tracing source and meter are registered automatically, so traces and metrics flow into the Aspire telemetry pipeline with no extra code
  • Keyed DI for multiple brokersAddKeyedKubeMQClient registers a distinct IKubeMQClient per named broker, resolved with [FromKeyedServices(...)]

The two packages

PackageProjectResponsibility
KubeMQ.Aspire.HostingAppHostProvision KubeMQ containers in the Aspire AppHost
KubeMQ.Aspire.ClientServiceConfigure IKubeMQClient with health checks, OpenTelemetry, and keyed DI

Install

Add the hosting package to your AppHost project:

dotnet add package KubeMQ.Aspire.Hosting

Add the client package to each service project that talks to KubeMQ:

dotnet add package KubeMQ.Aspire.Client

Quick start

Provision the broker in the AppHost and reference it from a service. The connection string flows from the container resource into the service automatically.

AppHost/Program.cs
var builder = DistributedApplication.CreateBuilder(args);

var kubemqKey = builder.AddParameter("kubemq-key", secret: true);

var messaging = builder.AddKubeMQ("messaging")
    .WithLicenseKey(kubemqKey)
    .WithDataVolume();

builder.AddProject<Projects.MyWebApi>("webapi")
    .WithReference(messaging)
    .WaitFor(messaging);

builder.Build().Run();
MyWebApi/Program.cs
var builder = WebApplication.CreateBuilder(args);

builder.AddKubeMQClient("messaging");

var app = builder.Build();
app.Run();

AddKubeMQClient registers IKubeMQClient as a singleton and resolves the broker address from the "messaging" connection string injected by WithReference. For the full walkthrough — parameters, secrets, and verifying the connection — see Getting Started.

Architecture

The AppHost provisions the KubeMQ container and injects its address as a connection string into each referencing service. In the service, AddKubeMQClient reads that connection string, constructs an IKubeMQClient that speaks gRPC to the broker on port 50000, and registers the health checks and OpenTelemetry instrumentation as side outputs into the Aspire pipeline.

The AppHost provisions the broker container and injects its host:port address; the service resolves it by connection name, builds an IKubeMQClient, and gets health checks and telemetry for free.

What the integration provisions

The hosting package provisions a real KubeMQ container; the client package layers Aspire conventions on top of the KubeMQ .NET SDK.

FeatureDetail
Container imageAddKubeMQ runs europe-docker.pkg.dev/kubemq/images/kubemq:2.5.0
gRPC endpointTarget port 50000 (TCP) — the primary client connection
REST endpointTarget port 9090 (HTTP)
Dashboard endpointTarget port 8080 (HTTP)
Persistent lifetimeThe container uses ContainerLifetime.Persistent, so it survives AppHost restarts
Persistent storageWithDataVolume() binds a volume to /store for durable messages
License keyWithLicenseKey() sets the KUBEMQ_TOKEN environment variable from a secret parameter
Image overrideWithImageTag() overrides the default image tag
Health checksReadiness (ready) and liveness (live) checks reporting the SDK connection state
OpenTelemetryTracing source and meter KubeMQ.Sdk registered by default
Keyed DIAddKeyedKubeMQClient for multiple named brokers in one service

Supported runtime

RequirementVersion
LanguageC# (.NET)
.NET runtime.NET 8.0 or .NET 9.0
.NET Aspire9.0+
KubeMQ.SDK.CSharp3.0.1
KubeMQ brokergRPC on :50000 (always on — no enable flag)

Messaging patterns

Once IKubeMQClient is injected, it speaks the full KubeMQ messaging surface through the native SDK. The capability pages document the Aspire-specific wiring and link out to the core pattern docs for the send/receive semantics.

Requirements — .NET 8.0 or .NET 9.0, .NET Aspire 9.0 or later, a KubeMQ license key set via WithLicenseKey(), and Docker for local development with Aspire.

New to KubeMQ? Start with the KubeMQ Getting Started guide for core concepts like Events, Queues, and RPC before wiring up Aspire.

Was this page helpful?

On this page