This is an unofficial client for Memphis, written in Rust.
Add the following to your Cargo.toml
file:
toml
[dependencies]
memphis-rust-community = "0.3.1"
```rust use memphisrustcommunity::memphisclient::MemphisClient; use memphisrustcommunity::consumer::MemphisConsumerOptions; use memphisrust_community::station::MemphisStationsOptions;
async fn main() { let client = MemphisClient::new("localhost:6666", "root", "memphis", None).await.unwrap();
let station_options = MemphisStationsOptions::new("my-station");
let station = client.create_station(station_options).await.unwrap();
let consumer_options = MemphisConsumerOptions::new("my-consumer")
.with_generate_unique_suffix(true);
let mut consumer = station.create_consumer(consumer_options).await.unwrap();
let mut message_receiver = consumer.consume().await.unwrap();
tokio::spawn(async move {
loop {
let msg = message_receiver.recv().await;
// Do something with the message
break;
}
});
} ```
```rust use memphisrustcommunity::memphisclient::MemphisClient; use memphisrustcommunity::producer::MemphisProducerOptions; use memphisrust_community::station::MemphisStationsOptions;
async fn main() { let client = MemphisClient::new("localhost:6666", "root", "memphis", None).await.unwrap();
let station_options = MemphisStationsOptions::new("my-station");
let station = client.create_station(station_options).await.unwrap();
let producer_options = MemphisProducerOptions::new("my-producer")
.with_generate_unique_suffix(true);
let mut producer = station.create_producer(producer_options).await.unwrap();
let msg = ComposableMessage::new()
.with_payload("Hello World!")
.with_header("TestHeader", "TestValue");
producer.produce(msg).await.unwrap();
} ```