| Crates.io | rabbitmq_streamer |
| lib.rs | rabbitmq_streamer |
| version | 0.2.0 |
| created_at | 2025-04-25 16:35:48.45722+00 |
| updated_at | 2025-05-05 17:10:46.346663+00 |
| description | A library to consume RabbiMQ streams |
| homepage | https://github.com/neurono-ml/rabbitmq_streamer |
| repository | https://github.com/neurono-ml/rabbitmq_streamer |
| max_upload_size | |
| id | 1649209 |
| size | 94,507 |
A library for streaming messages from RabbitMQ. It provides a high-level API for connecting to RabbitMQ and consuming messages from queues.
RabbitConsumer: A struct representing a RabbitMQ consumer that connects to a RabbitMQ broker, binds the specified queue to an exchange, and loads messages from the specified queue.
channel: A reference-counted handle to a channel used to receive messages.queue_name: The name of the queue where messages will be consumed.app_group_namespace: An identifier for the application used to create routing keys, which helps in segregating messages based on different applications or groups.RabbitPublisher: A struct representing a RabbitMQ publisher that connects to a RabbitMQ broker, binds the specified exchange, and publishes messages to it.
channel: A reference-counted handle to a channel used to send messages.exchange_name: The name of the exchange where messages will be published.app_group_namespace: An identifier for the application used to create routing keys, which helps in segregating messages based on different applications or groups.use rabbitmq_streammer::RabbitConsumer;
use futures::StreamExt;
use serde::Deserialize;
#[derive(Deserialize)]
struct Payload {
data: String,
id: u32,
}
#[tokio::main]
async fn main() {
let uri = "amqp://admin:password@pipe:5672";
let queue_name = "paylods";
let app_group_namespace = "test_application";
let exchange_name = "test";
let consumer = RabbitConsumer::connect(uri, queue_name, app_group_namespace, exchange_name).await.unwrap();
let mut messages = consumer.load_messages::<Vec<Payload>>(10, "test-tag").await.unwrap();
while let Some(message) = messages.next().await {
println!("Received message: {:?}", message);
}
}