Crate rabbitmq_stream_client

Source
Expand description

rabbitmq-stream-client

Experimental Rust client for RabbitMQ Stream

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?;

For more connection options check EnvironmentBuilder

§Publishing messages

use rabbitmq_stream_client::{Environment, types::Message};

let environment = Environment::builder().build().await?;
let producer = environment.producer().build("mystream").await?;

for i in 0..10 {
    producer
        .send_with_confirm(Message::builder().body(format!("message{}", i)).build())
        .await?;
}

producer.close().await?;

For more producer options check ProducerBuilder

§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?;

For more consumer options check ConsumerBuilder

Modules§

error
types

Structs§

Client
Raw API for taking to RabbitMQ stream
ClientOptions
ConfirmationStatus
Consumer
API for consuming RabbitMQ stream messages
ConsumerBuilder
Builder for Consumer
ConsumerHandle
Handler API for Consumer
Dedup
Environment
Main access point to a node
EnvironmentBuilder
Builder for Environment
FilterConfiguration
MessageContext
NoDedup
Producer
API for publising messages to RabbitMQ stream
ProducerBuilder
Builder for Producer
TlsConfigurationBuilder

Enums§

TlsConfiguration
Helper for tls configuration

Traits§

MetricsCollector
OnClosed

Type Aliases§

RabbitMQStreamResult