Debian Codegraph @

cpp/docs/overview.md

raw
1 # Overview {#overview_page}
2
3 Qpid Proton's concepts and capabilities closely match those of its
4 wire protocol, AMQP. See
5 [the Qpid AMQP page](https://qpid.apache.org/amqp/index.html) and
6 [the AMQP 1.0 spec](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html)
7 for more information.
8
9 ## Key concepts
10
11 A `proton::message` has a *body* (the main content), application
12 properties where you can store additional data, and specific
13 properties defined by AMQP.
14
15 Messages are transferred over *links*. The sending end of a link is a
16 `proton::sender`, and the receiving end is a `proton::receiver`.
17 Links have a *source* and *target* address, as explained
18 [below](#sources-and-targets).
19
20 Links are grouped in a `proton::session`. Messages in the same session
21 are sent sequentially, while those on different sessions can be
22 interleaved. A large message being sent on one session does not block
23 messages being sent on another session.
24
25 Sessions belong to a `proton::connection`. If you don't need multiple
26 sessions, a connection will create links directly using a default
27 session.
28
29 A `proton::delivery` represents the transfer of a message and allows
30 the receiver to accept or reject it. The sender can use a
31 `proton::tracker` to track the status of a sent message and find out
32 if it was accepted.
33
34 A delivery is *settled* when both ends are done with it. Different
35 settlement methods give different levels of reliability:
36 *at-most-once*, *at-least-once*, and *exactly-once*. See
37 [below](#delivery-guarantees).
38
39 ## The anatomy of a Proton application
40
41 `proton::container` is the top-level object in a Proton application.
42 A client uses `proton::container::connect()` to establish connections.
43 A server uses `proton::container::listen()` to accept connections.
44
45 Proton is an event-driven API. You implement a subclass of
46 `proton::messaging_handler` and override functions to handle AMQP
47 events, such as `on_container_open()` or `on_message()`. Each
48 connection is associated with a handler for its events.
49 `proton::container::run()` polls all connections and listeners and
50 dispatches events to your handlers.
51
52 A message body can be a string or byte sequence encoded any way you
53 like. However, AMQP also provides standard, interoperable encodings
54 for basic data types and structures such as maps and lists. You can
55 use this encoding for your message bodies via `proton::value` and
56 `proton::scalar`, which convert C++ types to their AMQP equivalents.
57
58 ## Sources and targets
59
60 Every link has two addresses, *source* and *target*. The most common
61 pattern for using these addresses is as follows.
62
63 When a client creates a *receiver* link, it sets the *source*
64 address. This means "I want to receive messages from this
65 source". This is often referred to as "subscribing" to the
66 source. When a client creates a *sender* link, it sets the *target*
67 address. This means "I want to send to this target".
68
69 In the case of a broker, the source or target usually refers to a
70 queue or topic. In general they can refer to any AMQP-capable node.
71
72 In the *request-response* pattern, a request message carries a
73 *reply-to* address for the response message. This can be any AMQP
74 address, but it is often useful to create a temporary address for the
75 response message. The client creates a *receiver* with no source
76 address and the *dynamic* flag set. The server generates a unique
77 *source* address for the receiver, which is discarded when the link
78 closes. The client uses this source address as the reply-to when it
79 sends the request, so the response is delivered to the client's
80 receiver.
81
82 The @ref server_direct.cpp example shows how to implement a
83 request-response server.
84
85 ## Delivery guarantees
86
87 Proton offers three levels of message delivery guarantee:
88 *at-most-once*, *at-least-once*, and *exactly-once*.
89
90 For *at-most-once*, the sender settles the message as soon as it sends
91 it. If the connection is lost before the message is received by the
92 receiver, the message will not be delivered.
93
94 For *at-least-once*, the receiver accepts and settles the message on
95 receipt. If the connection is lost before the sender is informed of
96 the settlement, then the delivery is considered in-doubt and should be
97 retried. This will ensure it eventually gets delivered (provided of
98 course the connection and link can be reestablished). It may mean that
99 it is delivered multiple times, however.
100
101 Finally, for *exactly-once*, the receiver accepts the message but
102 doesn't settle it. The sender settles once it is aware that the
103 receiver accepted it. In this way the receiver retains knowledge of an
104 accepted message until it is sure the sender knows it has been
105 accepted. If the connection is lost before settlement, the receiver
106 informs the sender of all the unsettled deliveries it knows about, and
107 from this the sender can deduce which need to be redelivered. The
108 sender likewise informs the receiver which deliveries it knows about,
109 from which the receiver can deduce which have already been settled.