File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,17 +47,18 @@ async fn main() -> Result<()> {
4747 FieldTable :: default ( ) ,
4848 )
4949 . await ?;
50- runtime. spawn ( async move {
50+ let cons = runtime. spawn ( async move {
5151 info ! ( "will consume" ) ;
5252 while let Some ( delivery) = consumer. next ( ) . await {
53- let delivery = delivery. expect ( "error in consumer" ) ;
54- delivery. ack ( BasicAckOptions :: default ( ) ) . await . expect ( "ack" ) ;
53+ let delivery = delivery? ;
54+ delivery. ack ( BasicAckOptions :: default ( ) ) . await ? ;
5555 }
56+ Ok ( ( ) )
5657 } ) ;
5758
5859 let payload = b"Hello world!" ;
5960
60- loop {
61+ for _ in 0 .. 1500000 {
6162 let confirm = channel_a
6263 . basic_publish (
6364 "" ,
@@ -70,4 +71,10 @@ async fn main() -> Result<()> {
7071 . await ?;
7172 assert_eq ! ( confirm, Confirmation :: NotRequested ) ;
7273 }
74+
75+ tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) . await ;
76+ channel_b
77+ . basic_cancel ( "my_consumer" , BasicCancelOptions :: default ( ) )
78+ . await ?;
79+ cons. await
7380}
You can’t perform that action at this time.
0 commit comments