/rabbitmq-stream-rust-client

A client library for RabbitMQ streams

Primary LanguageRustOtherNOASSERTION

RabbitMQ Stream Rust

A Work in progress Rust Client for RabbitMQ Stream

Tests status Download docs.rs docs deps codecov

RabbitMQ Stream Client

A Rust Client for RabbitMQ Stream Queues

Installation

Install from crates.io

[dependencies]
rabbitmq-stream-client = "*"

Quick Start

The main access point is Environment, which is used to connect to a node.

Example

Building the environment
use rabbitmq_stream_client::Environment;
let environment = Environment::builder().build().await?;
Publishing messages
use rabbitmq_stream_client::{Environment, types::Message};
let environment = Environment::builder().build().await?;
let producer = environment.producer().name("myproducer").build("mystream").await?;
for i in 0..10 {
    producer
        .send(Message::builder().body(format!("message{}", i)).build())
        .await?;
}
producer.close().await?;
Consuming messages
use rabbitmq_stream_client::{Environment};
use futures::StreamExt;
use tokio::task;
use tokio::time::{sleep, Duration};
let environment = Environment::builder().build().await?;
let mut consumer = environment.consumer().build("mystream").await?;
let handle = consumer.handle();
task::spawn(async move {
    while let Some(delivery) = consumer.next().await {
        println!("Got message {:?}",delivery);
    }
});
// wait 10 second and then close the consumer
sleep(Duration::from_secs(10)).await;
handle.close().await?;

Development

Compiling

git clone https://github.com/rabbitmq/rabbitmq-stream-rust-client .
make build

Running Tests

make rabbitmq-server
make test

Running Benchmarks

make rabbitmq-server
make run-benchmark