-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "receiver_auto_accept" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
tokio = { version = "1", features = ["net", "rt", "rt-multi-thread", "macros"] } | ||
fe2o3-amqp = { path = "../../fe2o3-amqp" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use fe2o3_amqp::{ | ||
connection::Connection, link::Receiver, session::Session, types::primitives::Value, Delivery, | ||
}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let mut connection = Connection::open("connection-1", "amqp://localhost:5672") | ||
.await | ||
.unwrap(); | ||
let mut session = Session::begin(&mut connection).await.unwrap(); | ||
let mut receiver = Receiver::builder() | ||
.name("rust-receiver-link-1") | ||
.source("q1") | ||
.auto_accept(true) // default is `false` | ||
.attach(&mut session) | ||
.await | ||
.unwrap(); | ||
|
||
// The delivery will be automatically accepted | ||
let delivery: Delivery<Value> = receiver.recv().await.unwrap(); | ||
|
||
receiver.close().await.unwrap(); | ||
session.end().await.unwrap(); | ||
connection.close().await.unwrap(); | ||
} |