first commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "worker"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
async-nats = { version = "0.46.0" }
|
||||
futures = { version = "0.3.32" }
|
||||
futures-executor = { version = "0.3.32" }
|
||||
tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] }
|
||||
@@ -0,0 +1,17 @@
|
||||
use futures::StreamExt;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let nats_client = async_nats::connect("nats://localhost:4222")
|
||||
.await
|
||||
.expect("Error creating nats client");
|
||||
let mut subscriber = nats_client
|
||||
.queue_subscribe("jobs", "download".to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Receive and process messages
|
||||
while let Some(message) = subscriber.next().await {
|
||||
println!("Received message {:?}", message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user