Rust Examples
Controlled BetaThese examples are tested against the current native API Cargo example targets and recorded expected output.
Guide
Tested Rust SDK workflows for Message Broker stream publish, replay, cursor commit, shared queue processing, retry, and dead-letter handling with controlled-beta route boundaries.
Current availability
Private Beta. Public beta is scheduled for .
These examples are tested against the current native API Cargo example targets and recorded expected output.
Product SME and docs QA still need to accept the exact SDK wording, route maturity notes, and whether these commands enter docs CI.
| Workflow | Status | Validation | Source |
|---|---|---|---|
| Publish, replay, and cursor commit | tested | cargo run --example publish_replay | docs/examples/message-broker/rust-sdk-examples/snippets/publish-replay.rs |
| Shared queue ack, nack, and redelivery | tested | cargo run --example shared_queue_processing | docs/examples/message-broker/rust-sdk-examples/snippets/shared-queue-processing.rs |
| HTTP queue retry, dead-letter, and DLQ replay | tested | cargo run --example http_queue_worker | docs/examples/message-broker/rust-sdk-examples/snippets/http-queue-worker.rs |
| Failure-policy retry exhaustion | tested | cargo run --example retry_dead_letter | docs/examples/message-broker/rust-sdk-examples/snippets/retry-dead-letter.rs |
The source snippets map to current Cargo example targets that compile and run with deterministic output.
The rendered page remains verification-required until Message Broker product SME and docs QA reviewers accept exact SDK wording and route maturity notes.
In-process examples use InMemoryBroker. The HTTP example uses a scripted transport, so live remote auth and network behavior stay tied to reference and compatibility docs.
Message Broker Rust SDK examples
Switch between tested Rust SDK example targets. Live endpoint auth and network behavior still belong to the HTTP reference.
Rust
docs/examples/message-broker/rust-sdk-examples/snippets/publish-replay.rs
Creates a local stream, publishes records, replays from earliest, and commits a cursor.
let broker = InMemoryBroker::with_start_time(Timestamp::from_unix_millis(10_000));
let mut client = NativeClient::new(broker, ClientConfig::new("telemetry-producer"))?;
client.create_stream(
"telemetry",
DurabilityMode::LocalDisk,
RetentionPolicy::default(),
)?;
let first = client.publish(
PublishMessage::new(
"telemetry",
Timestamp::from_unix_millis(1_700_000_000_000),
b"reading-1".to_vec(),
)
.with_message_id("reading-1")
.with_key(b"machine-17".to_vec()),
)?;
let batch = client.batch_publish(vec![
PublishMessage::new(
"telemetry",
Timestamp::from_unix_millis(1_700_000_000_001),
b"reading-2".to_vec(),
)
.with_message_id("reading-2"),
PublishMessage::new(
"telemetry",
Timestamp::from_unix_millis(1_700_000_000_002),
b"reading-3".to_vec(),
)
.with_message_id("reading-3"),
])?;
let replay = client.subscribe_replay("telemetry", "analytics", StartPosition::Earliest)?;
let fetched = client.fetch(&replay, 10)?;
client.commit_cursor("telemetry", "analytics", "processed", fetched.next_offset)?;| Behavior | SDK surface | Evidence | Maturity |
|---|---|---|---|
| Create stream with local-disk durability | NativeClient::create_stream | SMB-EVID-013 and publish_replay.rs | Controlled beta |
| Publish one record and a batch | PublishMessage, NativeClient::publish, NativeClient::batch_publish | SMB-EVID-013 and publish_replay.rs | Controlled beta |
| Replay from earliest and commit cursor | subscribe_replay, fetch, commit_cursor | SMB-EVID-013 and publish_replay.rs | Controlled beta |
| Fetch queue work and ack successful delivery | subscribe_queue, fetch, ack | SMB-EVID-013 and shared_queue_processing.rs | Controlled beta |
| Nack and redeliver work | nack and queue fetch | SMB-EVID-013 and shared_queue_processing.rs | Controlled beta |
| Retry and dead-letter through HTTP client | HttpNativeClient::retry_delivery and dead_letter | SMB-EVID-013 and http_queue_worker.rs | Verification required for live remote endpoint posture |
| Apply failure policy and inspect DLQ | configure_failure_policy and subscribe_replay | SMB-EVID-013 and retry_dead_letter.rs | Controlled beta with review-required wording |
These lines come from the current product example binaries. Keep them synthetic and update them only when the SDK example behavior changes.
Text
Expected Output
Safe deterministic output recorded from the current Rust example binaries.
workflow=publish_replay published_offsets=[0, 1, 2]
workflow=publish_replay replayed=3 next_offset=3
workflow=publish_replay committed_cursor=processed offset=3
workflow=shared_queue acked_offset=0 delivery_id=del-1
workflow=shared_queue nacked_offset=1 will_redeliver=true
workflow=shared_queue redelivered_offset=1 attempt=2
workflow=http_queue_worker retry_scheduled delivery_id=del-1 available_at=1700000000250
workflow=http_queue_worker dead_lettered source_offset=0 dead_letter_stream=jobs.dlq dead_letter_offset=0
workflow=http_queue_worker dlq_message_id=dead-letter:jobs:0:del-2 payload=job-1
workflow=retry_dead_letter first_action=ScheduledRetry available_at=30104
workflow=retry_dead_letter exhausted_action=DeadLettered dead_letter_stream=jobs.dlq dead_letter_offset=0
workflow=retry_dead_letter dlq_message_id=job-1.dead-letter.del-2 original_offset=0 attempt=2 reason=still unavailable| Command | What it proves | Reviewer status |
|---|---|---|
cargo check --quiet --manifest-path .../Service.MessageBroker/Cargo.toml -p stornamics-message-broker-native --examples | All native API Rust example targets compile. | passed on 2026-08-16 |
cargo run --quiet ... --example publish_replay | Stream publish, batch publish, replay count, next offset, and cursor commit output. | passed on 2026-08-16 |
cargo run --quiet ... --example shared_queue_processing | Queue ack, nack, redelivery, and delivery attempt output. | passed on 2026-08-16 |
cargo run --quiet ... --example http_queue_worker | HTTP client retry scheduling, dead-letter response parsing, and DLQ record listing with scripted transport. | passed on 2026-08-16 |
cargo run --quiet ... --example retry_dead_letter | Failure policy scheduled retry, retry exhaustion, dead-letter stream output, and DLQ replay metadata. | passed on 2026-08-16 |
Stream, replay, cursor, queue, retry, and dead-letter examples stay scoped to Message Broker controlled-beta behavior. Use the compatibility matrix before strengthening SDK, auth, replication, or Kafka compatibility claims.
Available: DOCS-023
Run the local quickstartUse the curl workflow for a copy/paste first success before adapting Rust SDK code.
Available: DOCS-032
Read CLI and SDK referenceUse lifecycle flags, diagnostics, remote boundaries, and SDK entry point names when extending examples.
Available: DOCS-040
Check route and auth scopeConfirm route maturity, auth modes, queue behavior, and Kafka boundaries before adding more SDK flows.
Available: DOCS-063
Add example validationUse the manifest gate alongside product Cargo checks before changing status or evidence wording.