1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! A minimal `RabbitMQ` service: one `#[subscriber]` handler on one queue.
//!
//! `LapinBroker::new` is synchronous and does no I/O, so the whole service fits the
//! `#[ruststream::app]` macro. The runtime connects the broker once at startup
//! (`Broker::connect`) before opening subscriptions, and the generated binary understands
//! `run` and `asyncapi gen`.
//!
//! The bare-string subscriber form consumes the queue named `orders` (which must already exist;
//! this crate does not create infrastructure unless the broker opts in, see the
//! `lapin_topology` example). Start a broker and create the queue first:
//!
//! ```text
//! just brokers-up
//! docker exec ruststream-rabbitmq rabbitmqadmin declare queue name=orders durable=true
//! cargo run --example lapin_quickstart -- run
//! ```
//!
//! Publish an order from another terminal:
//!
//! ```text
//! docker exec ruststream-rabbitmq rabbitmqadmin publish routing_key=orders payload='{"id":1}'
//! ```
// --8<-- [start:handler]
use ;
use subscriber;
use LapinBroker;
use Deserialize;
async
// --8<-- [end:handler]
// --8<-- [start:app]
// --8<-- [end:app]