#tokio #streaming #stomp #client #async #message #successor

tokio-stomp-2

Unofficial successor to Asynchronous streaming STOMP client

8 unstable releases (3 breaking)

0.3.0 Jun 28, 2023
0.2.0 Jun 28, 2023
0.1.1 Apr 9, 2021
0.0.4 Apr 7, 2021

#1191 in Asynchronous

Download history 48/week @ 2024-07-28 3/week @ 2024-08-11 16/week @ 2024-09-22 7/week @ 2024-09-29 44/week @ 2024-10-06 37/week @ 2024-10-13 39/week @ 2024-10-20 15/week @ 2024-10-27

135 downloads per month

MIT license

33KB
761 lines

Convinience Release

  • Use with care
  • If you don't know what you are doing, use the original tokio-stomp
  • Added sending and receiving headers

tokio-stomp-2

crates.io

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.

Examples

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

Dependencies

~6–14MB
~175K SLoC