Crates.io | tokio-stomp-2 |
lib.rs | tokio-stomp-2 |
version | 0.3.0 |
source | src |
created_at | 2021-04-07 14:54:38.28553 |
updated_at | 2023-06-28 13:19:40.36463 |
description | Unofficial successor to Asynchronous streaming STOMP client |
homepage | http://github.com/alexkunde/tokio-stomp-2 |
repository | http://github.com/alexkunde/tokio-stomp-2 |
max_upload_size | |
id | 380380 |
size | 52,961 |
An async STOMP client (and maybe eventually, server) for Rust, using the Tokio stack.
It aims to be fast and fully-featured with a simple streaming interface.
Sending a message to a queue.
use futures::prelude::*;
use tokio_stomp_2::client;
use tokio_stomp_2::ToServer;
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
let mut conn = client::connect("127.0.0.1:61613", None, None).await.unwrap();
conn.send(
ToServer::Send {
destination: "queue.test".into(),
transaction: None,
headers: vec!(),
body: Some(b"Hello there rustaceans!".to_vec()),
}
.into(),
)
.await.expect("sending message to server");
Ok(())
}
Receiving a message from a queue.
use futures::prelude::*;
use tokio_stomp_2::client;
use tokio_stomp_2::FromServer;
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
let mut conn = client::connect("127.0.0.1:61613", None, None).await.unwrap();
conn.send(client::subscribe("queue.test", "custom-subscriber-id")).await.unwrap();
while let Some(item) = conn.next().await {
if let FromServer::Message { message_id,body, .. } = item.unwrap().content {
println!("{:?}", body);
println!("{}", message_id);
}
}
Ok(())
}
For full examples, see the examples directory.
License: MIT