RocketMQ Rust Client
rocketmq-client-rust implements producers, transaction producers, Push
Consumers, Lite Pull Consumers and optional Admin APIs. Message domain types
live in rocketmq-model, wire types in
rocketmq-protocol, and networking in
rocketmq-transport.
Dependencies and runtime ownership
For an application beside these crates in this repository, use the following dependencies. External projects must adjust the paths:
[]
= { = "../rocketmq-client", = false }
= { = "../rocketmq-model" }
= { = "../rocketmq-runtime" }
= { = "../rocketmq-observability" }
= { = "1", = ["signal"] }
The application creates a RuntimeOwner and injects a ChildServiceContext
and TelemetryHandle into ClientRuntime::try_new. Producers, consumers and
Admin sessions share Arc<ClientRuntime>; the client never creates a fallback
runtime. Shut down client facades first, then the shared ClientRuntime, then
the RuntimeOwner. The application must inspect the shutdown reports.
Import public types from the crate root or prelude; internal module paths
are not supported import paths.
Producer example
Provision a running NameServer, Broker and TopicTest before running:
use ;
use Message;
use TelemetryRuntimeGuard;
use RuntimeOwner;
Push Consumer example
This complete async function accepts the application's client runtime. Invoke it on the owning RuntimeOwner, then close the shared ClientRuntime and RuntimeOwner after it returns.
use Arc;
use ;
use MessageExt;
;
async
Consumer APIs and message ownership
- Push Consumers support concurrent or orderly listeners and Tag/SQL92 subscriptions. The Broker must support the selected filtering capability.
- Lite Pull Consumers provide polling and offset management. Zero-copy polling
returns owned
Arc<MessageExt>values that may outlive a poll call; the underlying data remains retained while those messages live. The ordinary polling path that returns independent message values clones messages. - Runnable transaction, request/reply and queue-selection examples live in rocketmq-example.
Cargo features
| Feature | Behavior |
|---|---|
admin-full |
Package default; combines Admin reads and mutations. The root workspace dependency disables defaults so consumers select their required surface explicitly. |
admin-read / admin-mutation |
Enable query or mutation APIs; compile-time availability does not grant runtime permission. |
observability |
Enables client tracing integration. |
observability-metrics |
Enables client metrics integration. |
otlp-traces |
Enables OTLP trace export support; runtime configuration is still required. |
nameserver-dns-discovery |
Enables optional DNS discovery. |
test-support |
Exposes helpers for tests and benchmarks. |
There is no client tls feature. TLS depends on the transport crate's compiled
features and connection configuration; applications requiring TLS must enable
rocketmq-transport/tls in their dependency graph. The normal client transport
dependency enables SOCKS and does not independently enable TLS.
Validation
Select checks from the repository root for the changed area:
Network examples require a real cluster. Compilation alone does not verify delivery, retry, transaction or recovery behavior.