Skip to content

Commit e46527c

Browse files
committed
update crate readme
1 parent e324494 commit e46527c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

CRATE.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A rabbit MQ abstraction build upon [Lapin](https://crates.io/crates/lapin/1.0.2)
44

5-
## Example
5+
## Consumer example
66

77
```rust
88
fn main() {
@@ -21,6 +21,32 @@ fn handler(_delivery: &Delivery) -> HandleMessageResult {
2121
}
2222
```
2323

24+
## Publisher example
25+
26+
```rust
27+
fn main() {
28+
let config: JSONConfiguration = configuration::reader::read("./config.json").unwrap();
29+
println!("[{}] - Configuration read", line!(),);
30+
31+
LocalPool::new().run_until(async {
32+
loop {
33+
let outcome = publish(
34+
"test".to_string(),
35+
&config.binding.exchange,
36+
&config.binding.routing_key,
37+
config.connection.clone(),
38+
)
39+
.await;
40+
41+
println!("[{}] - {:?}", line!(), outcome);
42+
43+
let delay = time::Duration::from_millis(500);
44+
thread::sleep(delay);
45+
}
46+
});
47+
}
48+
```
49+
2450
## JSONConfiguration configuration example
2551

2652

0 commit comments

Comments
 (0)