YMJake.Aspire.Apache.RocketMQ 1.2.8

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

YMJake.Aspire.Apache.RocketMQ

Client-side helpers for using the published YMJake.RocketMQ.Client and YMJake.RocketMQ.Client.OpenTelemetry packages from .NET Aspire apps. The package can automatically wire RocketMQ health checks, logging, tracing, and metrics unless disabled in settings.

Use rocketmq as the Aspire connection name so the client binds to ConnectionStrings:rocketmq.

using Aspire.RocketMQ.Client;
using RocketMQ.Client.Core;
using System.Text;
using System.Collections.Generic;

var builder = WebApplication.CreateBuilder(args);

builder.AddRocketMQProducer(
    "rocketmq",
    settings =>
    {
        settings.EnableSsl = false;
        settings.MaxStartupAttempts = 10;
    },
    producer => producer.SetTopics("AspireRocketMQSmoke"));

builder.AddRocketMQConsumer(
    "rocketmq",
    settings =>
    {
        settings.EnableSsl = false;
        settings.MaxStartupAttempts = 10;
    },
    consumer => consumer
        .SetConsumerGroup("aspire-consumer-group")
        .SetSubscriptionExpression(new Dictionary<string, FilterExpression>
        {
            ["AspireRocketMQSmoke"] = new FilterExpression("*")
        })
        .SetAwaitDuration(TimeSpan.FromSeconds(3)));

var app = builder.Build();

app.MapGet("/rocketmq", (RocketMQProducerSettings rocketmq) => new
{
    rocketmq.Endpoints,
    rocketmq.RequestTimeout,
    rocketmq.EnableSsl,
    rocketmq.Namespace,
    rocketmq.MaxStartupAttempts
});

app.MapPost("/rocketmq/send", async (Producer producer) =>
{
    var message = new Message.Builder()
        .SetTopic("AspireRocketMQSmoke")
        .SetKeys(Guid.NewGuid().ToString("N"))
        .SetBody(Encoding.UTF8.GetBytes("hello from aspire"))
        .Build();

    var receipt = await producer.Send(message);
    return Results.Ok(new { receipt.MessageId, message.Topic });
});

app.MapPost("/rocketmq/consume", async (SimpleConsumer consumer, int? maxMessageNum, int? invisibleDurationMs) =>
{
    var safeInvisibleDurationMs = Math.Max(invisibleDurationMs.GetValueOrDefault(10_000), 10_000);
    var messages = await consumer.Receive(
        maxMessageNum.GetValueOrDefault(1),
        TimeSpan.FromMilliseconds(safeInvisibleDurationMs));

    return Results.Ok(messages.Select(message => new
    {
        message.MessageId,
        message.Topic,
        message.Keys,
        Body = Encoding.UTF8.GetString(message.Body)
    }));
});

app.Run();

If you are not using Aspire, you can configure the connection string directly:

using Aspire.RocketMQ.Client;
using RocketMQ.Client.Core;
using System.Text;

var builder = WebApplication.CreateBuilder(args);

builder.AddRocketMQProducer(
    settings =>
    {
        settings.ConnectionString = "127.0.0.1:8081";
        settings.EnableSsl = false;
        settings.MaxStartupAttempts = 10;
    },
    producer => producer.SetTopics("AspireRocketMQSmoke"));

var app = builder.Build();

app.MapPost("/rocketmq/send", async (Producer producer) =>
{
    var message = new Message.Builder()
        .SetTopic("AspireRocketMQSmoke")
        .SetKeys(Guid.NewGuid().ToString("N"))
        .SetBody(Encoding.UTF8.GetBytes("hello from standalone"))
        .Build();

    var receipt = await producer.Send(message);
    return Results.Ok(new { receipt.MessageId, message.Topic });
});

app.Run();

Consumer APIs

The package also exposes consumer-oriented registrations:

  • AddRocketMQConsumer(...) for SimpleConsumer
  • AddRocketMQPushConsumer(...) for PushConsumer
  • AddRocketMQLitePushConsumer(...) for LitePushConsumer
  • AddRocketMQLiteSimpleConsumer(...) for LiteSimpleConsumer is currently experimental and not recommended for RocketMQ 5.5.

Keyed overloads are available for multi-connection scenarios.

Configuration

Supported configuration keys:

  • ConnectionStrings:{name}
  • Aspire:Apache:RocketMQ:Producer:{name}:RequestTimeout
  • Aspire:Apache:RocketMQ:Producer:{name}:EnableSsl
  • Aspire:Apache:RocketMQ:Producer:{name}:DisableHealthChecks
  • Aspire:Apache:RocketMQ:Producer:{name}:DisableTracing
  • Aspire:Apache:RocketMQ:Producer:{name}:DisableMetrics
  • Aspire:Apache:RocketMQ:Producer:{name}:DisableLogging
  • Aspire:Apache:RocketMQ:Producer:{name}:Namespace
  • Aspire:Apache:RocketMQ:Producer:{name}:MaxStartupAttempts
  • Aspire:Apache:RocketMQ:Consumer:{name}:RequestTimeout
  • Aspire:Apache:RocketMQ:Consumer:{name}:EnableSsl
  • Aspire:Apache:RocketMQ:Consumer:{name}:DisableHealthChecks
  • Aspire:Apache:RocketMQ:Consumer:{name}:DisableTracing
  • Aspire:Apache:RocketMQ:Consumer:{name}:DisableMetrics
  • Aspire:Apache:RocketMQ:Consumer:{name}:DisableLogging
  • Aspire:Apache:RocketMQ:Consumer:{name}:Namespace
  • Aspire:Apache:RocketMQ:Consumer:{name}:MaxStartupAttempts

DisableLogging is honored by the client package and switches the underlying RocketMQ logger factory to a null logger for the process. DisableHealthChecks, DisableTracing, and DisableMetrics are also honored and control the automatic Aspire wiring for those integrations.

Example configuration:

{
  "Aspire": {
    "Apache": {
      "RocketMQ": {
        "Producer": {
          "rocketmq": {
            "EnableSsl": false,
            "MaxStartupAttempts": 10
          }
        },
        "Consumer": {
          "rocketmq": {
            "EnableSsl": false,
            "MaxStartupAttempts": 10
          }
        }
      }
    }
  }
}

For standalone apps, set ConnectionString directly on RocketMQProducerSettings or RocketMQConsumerSettings instead of using configuration binding. The connection string must point to the RocketMQ 5.x proxy gRPC endpoint, not the NameServer remoting endpoint.

Demo flow

The demo app uses the manual pull model:

  1. POST /rocketmq/send to publish a message.
  2. POST /rocketmq/consume?maxMessageNum=1 to pull messages.
  3. invisibleDurationMs must be at least 10000.

Notes

  • RocketMQ 5.5 cluster mode has been verified with Producer, SimpleConsumer, PushConsumer, LiteProducer, and LitePushConsumer.
  • AddRocketMQLitePushConsumer(...) requires a LITE topic and a consumer group configured with lite.bind.topic and lite.sub.model.
  • RocketMQ 5.5 local mode is not suitable for Lite consumer validation. LitePushConsumer fails there because the server-side local mode does not initialize LiteSubscriptionService.
  • AddRocketMQLiteSimpleConsumer(...) currently maps to LiteSimpleConsumer, but RocketMQ 5.5 proxy still throws server-side errors for LITE_SIMPLE_CONSUMER; treat it as experimental/unsupported for now.
  • MaxStartupAttempts is surfaced because the underlying client fetches topic routes during startup.
  • Health checks, tracing, and metrics are wired automatically by this package unless you disable them in settings. The underlying integration packages are still used internally.
  • AddRocketMQConsumer(...) uses SimpleConsumer, so its Receive(...) calls produce the visible receive trace shown in Aspire.
  • AddRocketMQPushConsumer(...) uses PushConsumer, and its Consume(...) callback now emits an independent consumer span linked back to the producer span.
  • AddRocketMQLitePushConsumer(...) follows the same linked-consumer span model as PushConsumer, while keeping the lite push subscription flow.

Deployment plan

  • The current hosting health checks use 127.0.0.1 because they are designed for local Aspire/AppHost development.
  • For Docker or Kubernetes deployments, the broker and proxy probe hosts should be made configurable so they can target service DNS names or in-cluster addresses instead of loopback.
  • The next release should keep the local defaults but expose an override path for non-local deployments.
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.2.8 103 5/21/2026
1.2.7 105 5/21/2026
1.2.6 101 5/7/2026
1.2.5 116 4/23/2026
1.2.4 135 4/5/2026
1.2.3 110 4/5/2026
1.2.1 114 4/5/2026
1.0.1 117 4/3/2026
1.0.0 113 4/2/2026