Commit 817a4d4
authored
Quorum Queue notifies AMQP client of Single Active Consumer state change (#15736)
* Notify AMQP 1.0 clients of Single Active Consumer status changes
Solves #14726
Quorum queues support the Single Active Consumer (SAC) feature, but
until now clients had no reliable way to learn whether they are the
active consumer or a waiting one. This commit adds consumer activity
notifications so that AMQP 1.0 consumers learn about their active/inactive
status after attaching and whenever it changes.
The notification is pushed via the `properties` field of the AMQP 1.0
flow frame, using a key `rabbitmq:active` with a boolean value.
This property is pushed to the client only upon SAC activity state
change, i.e. not in every flow frame to keep network traffic low.
On the server side, the existing `credit_reply` message sent from the
queue process to the session process is extended from a 6-tuple to a
7-tuple, where the 7th element is a map of link state properties
(e.g. `#{active => true}`). This reuses the existing communication
mechanism rather than introducing a new Ra event, and maps naturally to
the flow frame's `properties` field. It also allows future extensibility
for other queue types to convey additional link state information.
`rabbit_quorum_queue:consume/3` opts in by setting
`link_state_properties => true` in the consumer metadata. `rabbit_fifo`
uses this flag to decide whether to emit the 7-tuple (with properties)
or the old 6-tuple (without). This is how mixed-version cluster
compatibility is maintained: an old queue process sends the old 6-tuple
which `rabbit_amqp_session` converts to a 7-tuple with an empty map, and
a new queue process only sends the 7-tuple when the consumer opted in.
On the client side, amqp10_client emits a generic
`{amqp10_event, {link, LinkRef, {state_properties, Map}}}` event
whenever the flow frame's properties field changes, without baking in
any RabbitMQ-specific knowledge.
* Send link state properties also for non-SAC QQ1 parent 8c1041a commit 817a4d4
15 files changed
Lines changed: 877 additions & 198 deletions
File tree
- deps
- amqp10_client/src
- rabbit_common/src
- rabbitmq_shovel/src
- rabbit
- include
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
| 310 | + | |
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
148 | 151 | | |
149 | 152 | | |
150 | 153 | | |
| |||
414 | 417 | | |
415 | 418 | | |
416 | 419 | | |
417 | | - | |
418 | | - | |
419 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
420 | 423 | | |
421 | 424 | | |
422 | 425 | | |
| |||
976 | 979 | | |
977 | 980 | | |
978 | 981 | | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
979 | 986 | | |
980 | 987 | | |
981 | 988 | | |
| |||
987 | 994 | | |
988 | 995 | | |
989 | 996 | | |
990 | | - | |
991 | | - | |
| 997 | + | |
| 998 | + | |
992 | 999 | | |
993 | 1000 | | |
994 | 1001 | | |
| |||
1031 | 1038 | | |
1032 | 1039 | | |
1033 | 1040 | | |
1034 | | - | |
| 1041 | + | |
| 1042 | + | |
1035 | 1043 | | |
1036 | 1044 | | |
1037 | 1045 | | |
1038 | | - | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
1039 | 1052 | | |
1040 | 1053 | | |
1041 | 1054 | | |
| |||
1056 | 1069 | | |
1057 | 1070 | | |
1058 | 1071 | | |
1059 | | - | |
| 1072 | + | |
| 1073 | + | |
1060 | 1074 | | |
1061 | | - | |
| 1075 | + | |
| 1076 | + | |
1062 | 1077 | | |
1063 | 1078 | | |
1064 | 1079 | | |
| |||
1120 | 1135 | | |
1121 | 1136 | | |
1122 | 1137 | | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
1123 | 1151 | | |
1124 | 1152 | | |
1125 | 1153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments