Refactored BillEntry and relevant classes.
[aquarium] / doc / specs / amqp / amqp0-9-1.xml
1 <?xml version = "1.0"?>
2
3 <!--
4      WARNING: Modified from the official 0-9-1 specification XML by
5      the addition of:
6      confirm.select and confirm.select-ok,
7      exchange.bind and exchange.bind-ok,
8      exchange.unbind and exchange.unbind-ok,
9      basic.nack,
10      the ability for the Server to send basic.ack, basic.nack and
11       basic.cancel to the client, and
12      the un-deprecation of exchange.declare{auto-delete} and exchange.declare{internal}
13 -->
14
15 <!--
16     Copyright Notice
17     ================
18     Copyright (c) 2006-2008 Cisco Systems, Credit Suisse, Deutsche Boerse
19     Systems, Envoy Technologies, Inc., Goldman Sachs, IONA Technologies PLC,
20     iMatix Corporation, JPMorgan Chase Bank Inc. N.A, Novell, Rabbit
21     Technologies Ltd., Red Hat, Inc., TWIST Process Innovations Ltd, WS02
22     Inc. and 29West Inc. All rights reserved.
23
24     License
25     =======
26     Cisco Systems, Credit Suisse, Deutsche Boerse Systems, Envoy Technologies,
27     Inc., Goldman Sachs, IONA Technologies PLC, iMatix Corporation, JPMorgan
28     Chase Bank Inc. N.A, Novell, Rabbit Technologies Ltd., Red Hat, Inc.,
29     TWIST Process Innovations Ltd, WS02, Inc. and 29West Inc. (collectively,
30     the "Authors") each hereby grants to you a worldwide, perpetual,
31     royalty-free, nontransferable, nonexclusive license to (i) copy, display,
32     distribute and implement the Advanced Messaging Queue Protocol ("AMQP")
33     Specification and (ii) the Licensed Claims that are held by the Authors,
34     all for the purpose of implementing the Advanced Messaging Queue Protocol
35     Specification. Your license and any rights under this Agreement will
36     terminate immediately without notice from any Author if you bring any
37     claim, suit, demand, or action related to the Advanced Messaging Queue
38     Protocol Specification against any Author. Upon termination, you shall
39     destroy all copies of the Advanced Messaging Queue Protocol Specification
40     in your possession or control.
41
42     As used hereunder, "Licensed Claims" means those claims of a patent or
43     patent application, throughout the world, excluding design patents and
44     design registrations, owned or controlled, or that can be sublicensed
45     without fee and in compliance with the requirements of this Agreement,
46     by an Author or its affiliates now or at any future time and which would
47     necessarily be infringed by implementation of the Advanced Messaging
48     Queue Protocol Specification. A claim is necessarily infringed hereunder
49     only when it is not possible to avoid infringing it because there is no
50     plausible non-infringing alternative for implementing the required
51     portions of the Advanced Messaging Queue Protocol Specification.
52     Notwithstanding the foregoing, Licensed Claims shall not include any
53     claims other than as set forth above even if contained in the same patent
54     as Licensed Claims; or that read solely on any implementations of any
55     portion of the Advanced Messaging Queue Protocol Specification that are
56     not required by the Advanced Messaging Queue ProtocolSpecification, or
57     that, if licensed, would require a payment of royalties by the licensor
58     to unaffiliated third parties. Moreover, Licensed Claims shall not
59     include (i) any enabling technologies that may be necessary to make or
60     use any Licensed Product but are not themselves expressly set forth in
61     the Advanced Messaging Queue Protocol Specification (e.g., semiconductor
62     manufacturing technology, compiler technology, object oriented
63     technology, networking technology, operating system technology, and the
64     like); or (ii) the implementation of other published standards developed
65     elsewhere and merely referred to in the body of the Advanced Messaging
66     Queue Protocol Specification, or (iii) any Licensed Product and any
67     combinations thereof the purpose or function of which is not required
68     for compliance with the Advanced Messaging Queue Protocol Specification.
69     For purposes of this definition, the Advanced Messaging Queue Protocol
70     Specification shall be deemed to include both architectural and
71     interconnection requirements essential for interoperability and may also
72     include supporting source code artifacts where such architectural,
73     interconnection requirements and source code artifacts are expressly
74     identified as being required or documentation to achieve compliance with
75     the Advanced Messaging Queue Protocol Specification.
76
77     As used hereunder, "Licensed Products" means only those specific portions
78     of products (hardware, software or combinations thereof) that implement
79     and are compliant with all relevant portions of the Advanced Messaging
80     Queue Protocol Specification.
81
82     The following disclaimers, which you hereby also acknowledge as to any
83     use you may make of the Advanced Messaging Queue Protocol Specification:
84
85     THE ADVANCED MESSAGING QUEUE PROTOCOL SPECIFICATION IS PROVIDED "AS IS,"
86     AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
87     IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
88     FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE
89     CONTENTS OF THE ADVANCED MESSAGING QUEUE PROTOCOL SPECIFICATION ARE
90     SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF THE ADVANCED
91     MESSAGING QUEUE PROTOCOL SPECIFICATION WILL NOT INFRINGE ANY THIRD PARTY
92     PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
93
94     THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
95     INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY
96     USE, IMPLEMENTATION OR DISTRIBUTION OF THE ADVANCED MESSAGING QUEUE
97     PROTOCOL SPECIFICATION.
98
99     The name and trademarks of the Authors may NOT be used in any manner,
100     including advertising or publicity pertaining to the Advanced Messaging
101     Queue Protocol Specification or its contents without specific, written
102     prior permission. Title to copyright in the Advanced Messaging Queue
103     Protocol Specification will at all times remain with the Authors.
104
105     No other rights are granted by implication, estoppel or otherwise.
106
107     Upon termination of your license or rights under this Agreement, you
108     shall destroy all copies of the Advanced Messaging Queue Protocol
109     Specification in your possession or control.
110
111     Trademarks
112     ==========
113     JPMorgan, JPMorgan Chase, Chase, the JPMorgan Chase logo and the
114     Octagon Symbol are trademarks of JPMorgan Chase & Co.
115
116     IMATIX and the iMatix logo are trademarks of iMatix Corporation sprl.
117
118     IONA, IONA Technologies, and the IONA logos are trademarks of IONA
119     Technologies PLC and/or its subsidiaries.
120
121     LINUX is a trademark of Linus Torvalds. RED HAT and JBOSS are registered
122     trademarks of Red Hat, Inc. in the US and other countries.
123
124     Java, all Java-based trademarks and OpenOffice.org are trademarks of
125     Sun Microsystems, Inc. in the United States, other countries, or both.
126
127     Other company, product, or service names may be trademarks or service
128     marks of others.
129
130     Links to full AMQP specification:
131     =================================
132     http://www.amqp.org
133 -->
134
135 <!--
136     <!DOCTYPE amqp SYSTEM "amqp.dtd">
137 -->
138
139 <!-- XML Notes
140
141     We use entities to indicate repetition; attributes to indicate properties.
142
143     We use the 'name' attribute as an identifier, usually within the context
144     of the surrounding entities.
145
146     We use spaces to seperate words in names, so that we can print names in
147     their natural form depending on the context - underlines for source code,
148     hyphens for written text, etc.
149
150     We do not enforce any particular validation mechanism but we support all
151     mechanisms.  The protocol definition conforms to a formal grammar that is
152     published seperately in several technologies.
153
154  -->
155
156 <amqp major = "0" minor = "9" revision = "1"
157     port = "5672" comment = "AMQ Protocol version 0-9-1">
158   <!--
159       ======================================================
160       ==       CONSTANTS
161       ======================================================
162   -->
163   <!-- Frame types -->
164   <constant name = "frame-method"     value = "1" />
165   <constant name = "frame-header"     value = "2" />
166   <constant name = "frame-body"       value = "3" />
167   <constant name = "frame-heartbeat"  value = "8" />
168
169   <!-- Protocol constants -->
170   <constant name = "frame-min-size"   value = "4096" />
171   <constant name = "frame-end"        value = "206" />
172
173   <!-- Reply codes -->
174   <constant name = "reply-success" value = "200">
175     <doc>
176       Indicates that the method completed successfully. This reply code is
177       reserved for future use - the current protocol design does not use positive
178       confirmation and reply codes are sent only in case of an error.
179     </doc>
180   </constant>
181
182   <constant name = "content-too-large" value = "311" class = "soft-error">
183     <doc>
184       The client attempted to transfer content larger than the server could accept
185       at the present time. The client may retry at a later time.
186     </doc>
187   </constant>
188
189   <constant name = "no-consumers" value = "313" class = "soft-error">
190     <doc>
191       When the exchange cannot deliver to a consumer when the immediate flag is
192       set. As a result of pending data on the queue or the absence of any
193       consumers of the queue.
194     </doc>
195   </constant>
196
197   <constant name = "connection-forced" value = "320" class = "hard-error">
198     <doc>
199       An operator intervened to close the connection for some reason. The client
200       may retry at some later date.
201     </doc>
202   </constant>
203
204   <constant name = "invalid-path" value = "402" class = "hard-error">
205     <doc>
206       The client tried to work with an unknown virtual host.
207     </doc>
208   </constant>
209
210   <constant name = "access-refused" value = "403" class = "soft-error">
211     <doc>
212       The client attempted to work with a server entity to which it has no
213       access due to security settings.
214     </doc>
215   </constant>
216
217   <constant name = "not-found" value = "404" class = "soft-error">
218     <doc>
219       The client attempted to work with a server entity that does not exist.
220     </doc>
221   </constant>
222
223   <constant name = "resource-locked" value = "405" class = "soft-error">
224     <doc>
225       The client attempted to work with a server entity to which it has no
226       access because another client is working with it.
227     </doc>
228   </constant>
229
230   <constant name = "precondition-failed" value = "406" class = "soft-error">
231     <doc>
232       The client requested a method that was not allowed because some precondition
233       failed.
234     </doc>
235   </constant>
236
237   <constant name = "frame-error" value = "501" class = "hard-error">
238     <doc>
239       The sender sent a malformed frame that the recipient could not decode.
240       This strongly implies a programming error in the sending peer.
241     </doc>
242   </constant>
243
244   <constant name = "syntax-error" value = "502" class = "hard-error">
245     <doc>
246       The sender sent a frame that contained illegal values for one or more
247       fields. This strongly implies a programming error in the sending peer.
248     </doc>
249   </constant>
250
251   <constant name = "command-invalid" value = "503" class = "hard-error">
252     <doc>
253       The client sent an invalid sequence of frames, attempting to perform an
254       operation that was considered invalid by the server. This usually implies
255       a programming error in the client.
256     </doc>
257   </constant>
258
259   <constant name = "channel-error" value = "504" class = "hard-error">
260     <doc>
261       The client attempted to work with a channel that had not been correctly
262       opened. This most likely indicates a fault in the client layer.
263     </doc>
264   </constant>
265
266   <constant name = "unexpected-frame" value = "505" class = "hard-error">
267     <doc>
268       The peer sent a frame that was not expected, usually in the context of
269       a content header and body.  This strongly indicates a fault in the peer's
270       content processing.
271     </doc>
272   </constant>
273
274   <constant name = "resource-error" value = "506" class = "hard-error">
275     <doc>
276       The server could not complete the method because it lacked sufficient
277       resources. This may be due to the client creating too many of some type
278       of entity.
279     </doc>
280   </constant>
281
282   <constant name = "not-allowed" value = "530" class = "hard-error">
283     <doc>
284       The client tried to work with some entity in a manner that is prohibited
285       by the server, due to security settings or by some other criteria.
286     </doc>
287   </constant>
288
289   <constant name = "not-implemented" value = "540" class = "hard-error">
290     <doc>
291       The client tried to use functionality that is not implemented in the
292       server.
293     </doc>
294   </constant>
295
296   <constant name = "internal-error" value = "541" class = "hard-error">
297     <doc>
298       The server could not complete the method because of an internal error.
299       The server may require intervention by an operator in order to resume
300       normal operations.
301     </doc>
302   </constant>
303
304   <!--
305       ======================================================
306       ==       DOMAIN TYPES
307       ======================================================
308   -->
309
310   <domain name = "class-id" type = "short" />
311
312   <domain name = "consumer-tag" type = "shortstr" label = "consumer tag">
313     <doc>
314       Identifier for the consumer, valid within the current channel.
315     </doc>
316   </domain>
317
318   <domain name = "delivery-tag" type = "longlong" label = "server-assigned delivery tag">
319     <doc>
320       The server-assigned and channel-specific delivery tag
321     </doc>
322     <rule name = "channel-local">
323       <doc>
324         The delivery tag is valid only within the channel from which the message was
325         received. I.e. a client MUST NOT receive a message on one channel and then
326         acknowledge it on another.
327       </doc>
328     </rule>
329     <rule name = "non-zero">
330       <doc>
331         The server MUST NOT use a zero value for delivery tags. Zero is reserved
332         for client use, meaning "all messages so far received".
333       </doc>
334     </rule>
335   </domain>
336
337   <domain name = "exchange-name" type = "shortstr" label = "exchange name">
338     <doc>
339       The exchange name is a client-selected string that identifies the exchange for
340       publish methods.
341     </doc>
342     <assert check = "length" value = "127" />
343     <assert check = "regexp" value = "^[a-zA-Z0-9-_.:]*$" />
344   </domain>
345
346   <domain name = "method-id" type = "short" />
347
348   <domain name = "no-ack" type = "bit" label = "no acknowledgement needed">
349     <doc>
350       If this field is set the server does not expect acknowledgements for
351       messages. That is, when a message is delivered to the client the server
352       assumes the delivery will succeed and immediately dequeues it. This
353       functionality may increase performance but at the cost of reliability.
354       Messages can get lost if a client dies before they are delivered to the
355       application.
356     </doc>
357   </domain>
358
359   <domain name = "no-local" type = "bit" label = "do not deliver own messages">
360     <doc>
361       If the no-local field is set the server will not send messages to the connection that
362       published them.
363     </doc>
364   </domain>
365
366   <domain name = "no-wait" type = "bit" label = "do not send reply method">
367     <doc>
368       If set, the server will not respond to the method. The client should not wait
369       for a reply method. If the server could not complete the method it will raise a
370       channel or connection exception.
371     </doc>
372   </domain>
373
374   <domain name = "path" type = "shortstr">
375     <doc>
376       Unconstrained.
377     </doc>
378     <assert check = "notnull" />
379     <assert check = "length" value = "127" />
380   </domain>
381
382   <domain name = "peer-properties" type = "table">
383     <doc>
384       This table provides a set of peer properties, used for identification, debugging,
385       and general information.
386     </doc>
387   </domain>
388
389   <domain name = "queue-name" type = "shortstr" label = "queue name">
390     <doc>
391       The queue name identifies the queue within the vhost.  In methods where the queue
392       name may be blank, and that has no specific significance, this refers to the
393       'current' queue for the channel, meaning the last queue that the client declared
394       on the channel.  If the client did not declare a queue, and the method needs a
395       queue name, this will result in a 502 (syntax error) channel exception.
396     </doc>
397     <assert check = "length" value = "127" />
398     <assert check = "regexp" value = "^[a-zA-Z0-9-_.:]*$" />
399   </domain>
400
401   <domain name = "redelivered" type = "bit" label = "message is being redelivered">
402     <doc>
403       This indicates that the message has been previously delivered to this or
404       another client.
405     </doc>
406     <rule name = "implementation">
407       <doc>
408         The server SHOULD try to signal redelivered messages when it can. When
409         redelivering a message that was not successfully acknowledged, the server
410         SHOULD deliver it to the original client if possible.
411       </doc>
412       <doc type = "scenario">
413         Declare a shared queue and publish a message to the queue.  Consume the
414         message using explicit acknowledgements, but do not acknowledge the
415         message.  Close the connection, reconnect, and consume from the queue
416         again.  The message should arrive with the redelivered flag set.
417       </doc>
418     </rule>
419     <rule name = "hinting">
420       <doc>
421         The client MUST NOT rely on the redelivered field but should take it as a
422         hint that the message may already have been processed. A fully robust
423         client must be able to track duplicate received messages on non-transacted,
424         and locally-transacted channels.
425       </doc>
426     </rule>
427   </domain>
428
429   <domain name = "message-count" type = "long" label = "number of messages in queue">
430     <doc>
431       The number of messages in the queue, which will be zero for newly-declared
432       queues. This is the number of messages present in the queue, and committed
433       if the channel on which they were published is transacted, that are not
434       waiting acknowledgement.
435     </doc>
436   </domain>
437
438   <domain name = "reply-code" type = "short" label = "reply code from server">
439     <doc>
440       The reply code. The AMQ reply codes are defined as constants at the start
441       of this formal specification.
442     </doc>
443     <assert check = "notnull" />
444   </domain>
445
446   <domain name = "reply-text" type = "shortstr" label = "localised reply text">
447     <doc>
448       The localised reply text. This text can be logged as an aid to resolving
449       issues.
450     </doc>
451     <assert check = "notnull" />
452   </domain>
453
454   <!-- Elementary domains -->
455   <domain name = "bit"        type = "bit"       label = "single bit" />
456   <domain name = "octet"      type = "octet"     label = "single octet" />
457   <domain name = "short"      type = "short"     label = "16-bit integer" />
458   <domain name = "long"       type = "long"      label = "32-bit integer" />
459   <domain name = "longlong"   type = "longlong"  label = "64-bit integer" />
460   <domain name = "shortstr"   type = "shortstr"  label = "short string" />
461   <domain name = "longstr"    type = "longstr"   label = "long string" />
462   <domain name = "timestamp"  type = "timestamp" label = "64-bit timestamp" />
463   <domain name = "table"      type = "table"     label = "field table" />
464
465   <!-- ==  CONNECTION  ======================================================= -->
466
467   <class name = "connection" handler = "connection" index = "10" label = "work with socket connections">
468     <doc>
469       The connection class provides methods for a client to establish a network connection to
470       a server, and for both peers to operate the connection thereafter.
471     </doc>
472
473     <doc type = "grammar">
474       connection          = open-connection *use-connection close-connection
475       open-connection     = C:protocol-header
476                             S:START C:START-OK
477                             *challenge
478                             S:TUNE C:TUNE-OK
479                             C:OPEN S:OPEN-OK
480       challenge           = S:SECURE C:SECURE-OK
481       use-connection      = *channel
482       close-connection    = C:CLOSE S:CLOSE-OK
483                           / S:CLOSE C:CLOSE-OK
484     </doc>
485
486     <chassis name = "server" implement = "MUST" />
487     <chassis name = "client" implement = "MUST" />
488
489     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
490
491     <method name = "start" synchronous = "1" index = "10" label = "start connection negotiation">
492       <doc>
493         This method starts the connection negotiation process by telling the client the
494         protocol version that the server proposes, along with a list of security mechanisms
495         which the client can use for authentication.
496       </doc>
497
498       <rule name = "protocol-name">
499         <doc>
500           If the server cannot support the protocol specified in the protocol header,
501           it MUST respond with a valid protocol header and then close the socket
502           connection.
503         </doc>
504         <doc type = "scenario">
505           The client sends a protocol header containing an invalid protocol name.
506           The server MUST respond by sending a valid protocol header and then closing
507           the connection.
508         </doc>
509       </rule>
510       <rule name = "server-support">
511         <doc>
512           The server MUST provide a protocol version that is lower than or equal to
513           that requested by the client in the protocol header.
514         </doc>
515         <doc type = "scenario">
516           The client requests a protocol version that is higher than any valid
517           implementation, e.g. 2.0.  The server must respond with a protocol header
518           indicating its supported protocol version, e.g. 1.0.
519         </doc>
520       </rule>
521       <rule name = "client-support">
522         <doc>
523           If the client cannot handle the protocol version suggested by the server
524           it MUST close the socket connection without sending any further data.
525         </doc>
526         <doc type = "scenario">
527           The server sends a protocol version that is lower than any valid
528           implementation, e.g. 0.1.  The client must respond by closing the
529           connection without sending any further data.
530         </doc>
531       </rule>
532
533       <chassis name = "client" implement = "MUST" />
534       <response name = "start-ok" />
535
536       <field name = "version-major" domain = "octet" label = "protocol major version">
537         <doc>
538           The major version number can take any value from 0 to 99 as defined in the
539           AMQP specification.
540         </doc>
541       </field>
542
543       <field name = "version-minor" domain = "octet" label = "protocol minor version">
544         <doc>
545           The minor version number can take any value from 0 to 99 as defined in the
546           AMQP specification.
547         </doc>
548       </field>
549
550       <field name = "server-properties" domain = "peer-properties" label = "server properties">
551         <rule name = "required-fields">
552           <doc>
553             The properties SHOULD contain at least these fields: "host", specifying the
554             server host name or address, "product", giving the name of the server product,
555             "version", giving the name of the server version, "platform", giving the name
556             of the operating system, "copyright", if appropriate, and "information", giving
557             other general information.
558           </doc>
559           <doc type = "scenario">
560             Client connects to server and inspects the server properties. It checks for
561             the presence of the required fields.
562           </doc>
563         </rule>
564       </field>
565
566       <field name = "mechanisms" domain = "longstr" label = "available security mechanisms">
567         <doc>
568           A list of the security mechanisms that the server supports, delimited by spaces.
569         </doc>
570         <assert check = "notnull" />
571       </field>
572
573       <field name = "locales" domain = "longstr" label = "available message locales">
574         <doc>
575           A list of the message locales that the server supports, delimited by spaces. The
576           locale defines the language in which the server will send reply texts.
577         </doc>
578         <rule name = "required-support">
579           <doc>
580             The server MUST support at least the en_US locale.
581           </doc>
582           <doc type = "scenario">
583             Client connects to server and inspects the locales field. It checks for
584             the presence of the required locale(s).
585           </doc>
586         </rule>
587         <assert check = "notnull" />
588       </field>
589     </method>
590
591     <method name = "start-ok" synchronous = "1" index = "11"
592       label = "select security mechanism and locale">
593       <doc>
594         This method selects a SASL security mechanism.
595       </doc>
596
597       <chassis name = "server" implement = "MUST" />
598
599       <field name = "client-properties" domain = "peer-properties" label = "client properties">
600         <rule name = "required-fields">
601           <!-- This rule is not testable from the client side -->
602           <doc>
603             The properties SHOULD contain at least these fields: "product", giving the name
604             of the client product, "version", giving the name of the client version, "platform",
605             giving the name of the operating system, "copyright", if appropriate, and
606             "information", giving other general information.
607           </doc>
608         </rule>
609       </field>
610
611       <field name = "mechanism" domain = "shortstr" label = "selected security mechanism">
612         <doc>
613           A single security mechanisms selected by the client, which must be one of those
614           specified by the server.
615         </doc>
616         <rule name = "security">
617           <doc>
618             The client SHOULD authenticate using the highest-level security profile it
619             can handle from the list provided by the server.
620           </doc>
621         </rule>
622         <rule name = "validity">
623           <doc>
624             If the mechanism field does not contain one of the security mechanisms
625             proposed by the server in the Start method, the server MUST close the
626             connection without sending any further data.
627           </doc>
628           <doc type = "scenario">
629             Client connects to server and sends an invalid security mechanism. The
630             server must respond by closing the connection (a socket close, with no
631             connection close negotiation).
632           </doc>
633         </rule>
634         <assert check = "notnull" />
635       </field>
636
637       <field name = "response" domain = "longstr" label = "security response data">
638         <doc>
639           A block of opaque data passed to the security mechanism. The contents of this
640           data are defined by the SASL security mechanism.
641         </doc>
642         <assert check = "notnull" />
643       </field>
644
645       <field name = "locale" domain = "shortstr" label = "selected message locale">
646         <doc>
647           A single message locale selected by the client, which must be one of those
648           specified by the server.
649         </doc>
650         <assert check = "notnull" />
651       </field>
652     </method>
653
654     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
655
656     <method name = "secure" synchronous = "1" index = "20" label = "security mechanism challenge">
657       <doc>
658         The SASL protocol works by exchanging challenges and responses until both peers have
659         received sufficient information to authenticate each other. This method challenges
660         the client to provide more information.
661       </doc>
662
663       <chassis name = "client" implement = "MUST" />
664       <response name = "secure-ok" />
665
666       <field name = "challenge" domain = "longstr" label = "security challenge data">
667         <doc>
668           Challenge information, a block of opaque binary data passed to the security
669           mechanism.
670         </doc>
671       </field>
672     </method>
673
674     <method name = "secure-ok" synchronous = "1" index = "21" label = "security mechanism response">
675       <doc>
676         This method attempts to authenticate, passing a block of SASL data for the security
677         mechanism at the server side.
678       </doc>
679
680       <chassis name = "server" implement = "MUST" />
681
682       <field name = "response" domain = "longstr" label = "security response data">
683         <doc>
684           A block of opaque data passed to the security mechanism. The contents of this
685           data are defined by the SASL security mechanism.
686         </doc>
687         <assert check = "notnull" />
688       </field>
689     </method>
690
691     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
692
693     <method name = "tune" synchronous = "1" index = "30"
694       label = "propose connection tuning parameters">
695       <doc>
696         This method proposes a set of connection configuration values to the client. The
697         client can accept and/or adjust these.
698       </doc>
699
700       <chassis name = "client" implement = "MUST" />
701
702       <response name = "tune-ok" />
703
704       <field name = "channel-max" domain = "short" label = "proposed maximum channels">
705         <doc>
706           Specifies highest channel number that the server permits.  Usable channel numbers
707           are in the range 1..channel-max.  Zero indicates no specified limit.
708         </doc>
709       </field>
710
711       <field name = "frame-max" domain = "long" label = "proposed maximum frame size">
712         <doc>
713           The largest frame size that the server proposes for the connection, including
714           frame header and end-byte.  The client can negotiate a lower value. Zero means
715           that the server does not impose any specific limit but may reject very large
716           frames if it cannot allocate resources for them.
717         </doc>
718         <rule name = "minimum">
719           <doc>
720             Until the frame-max has been negotiated, both peers MUST accept frames of up
721             to frame-min-size octets large, and the minimum negotiated value for frame-max
722             is also frame-min-size.
723           </doc>
724           <doc type = "scenario">
725             Client connects to server and sends a large properties field, creating a frame
726             of frame-min-size octets.  The server must accept this frame.
727           </doc>
728         </rule>
729       </field>
730
731       <field name = "heartbeat" domain = "short" label = "desired heartbeat delay">
732         <doc>
733           The delay, in seconds, of the connection heartbeat that the server wants.
734           Zero means the server does not want a heartbeat.
735         </doc>
736       </field>
737     </method>
738
739     <method name = "tune-ok" synchronous = "1" index = "31"
740       label = "negotiate connection tuning parameters">
741       <doc>
742         This method sends the client's connection tuning parameters to the server.
743         Certain fields are negotiated, others provide capability information.
744       </doc>
745
746       <chassis name = "server" implement = "MUST" />
747
748       <field name = "channel-max" domain = "short" label = "negotiated maximum channels">
749         <doc>
750           The maximum total number of channels that the client will use per connection.
751         </doc>
752         <rule name = "upper-limit">
753           <doc>
754             If the client specifies a channel max that is higher than the value provided
755             by the server, the server MUST close the connection without attempting a
756             negotiated close.  The server may report the error in some fashion to assist
757             implementors.
758           </doc>
759         </rule>
760         <assert check = "notnull" />
761         <assert check = "le" method = "tune" field = "channel-max" />
762       </field>
763
764       <field name = "frame-max" domain = "long" label = "negotiated maximum frame size">
765         <doc>
766           The largest frame size that the client and server will use for the connection.
767           Zero means that the client does not impose any specific limit but may reject
768           very large frames if it cannot allocate resources for them. Note that the
769           frame-max limit applies principally to content frames, where large contents can
770           be broken into frames of arbitrary size.
771         </doc>
772         <rule name = "minimum">
773           <doc>
774             Until the frame-max has been negotiated, both peers MUST accept frames of up
775             to frame-min-size octets large, and the minimum negotiated value for frame-max
776             is also frame-min-size.
777           </doc>
778         </rule>
779         <rule name = "upper-limit">
780           <doc>
781             If the client specifies a frame max that is higher than the value provided
782             by the server, the server MUST close the connection without attempting a
783             negotiated close. The server may report the error in some fashion to assist
784             implementors.
785           </doc>
786         </rule>
787       </field>
788
789       <field name = "heartbeat" domain = "short" label = "desired heartbeat delay">
790         <doc>
791           The delay, in seconds, of the connection heartbeat that the client wants. Zero
792           means the client does not want a heartbeat.
793         </doc>
794       </field>
795     </method>
796
797     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
798
799     <method name = "open" synchronous = "1" index = "40" label = "open connection to virtual host">
800       <doc>
801         This method opens a connection to a virtual host, which is a collection of
802         resources, and acts to separate multiple application domains within a server.
803         The server may apply arbitrary limits per virtual host, such as the number
804         of each type of entity that may be used, per connection and/or in total.
805       </doc>
806
807       <chassis name = "server" implement = "MUST" />
808       <response name = "open-ok" />
809
810       <field name = "virtual-host" domain = "path" label = "virtual host name">
811         <doc>
812           The name of the virtual host to work with.
813         </doc>
814         <rule name = "separation">
815           <doc>
816             If the server supports multiple virtual hosts, it MUST enforce a full
817             separation of exchanges, queues, and all associated entities per virtual
818             host. An application, connected to a specific virtual host, MUST NOT be able
819             to access resources of another virtual host.
820           </doc>
821         </rule>
822         <rule name = "security">
823           <doc>
824             The server SHOULD verify that the client has permission to access the
825             specified virtual host.
826           </doc>
827         </rule>
828       </field>
829       <!-- Deprecated: "capabilities", must be zero -->
830       <field name = "reserved-1" type = "shortstr" reserved = "1" />
831       <!-- Deprecated: "insist", must be zero -->
832       <field name = "reserved-2" type = "bit" reserved = "1" />
833     </method>
834
835     <method name = "open-ok" synchronous = "1" index = "41" label = "signal that connection is ready">
836       <doc>
837         This method signals to the client that the connection is ready for use.
838       </doc>
839       <chassis name = "client" implement = "MUST" />
840       <!-- Deprecated: "known-hosts", must be zero -->
841       <field name = "reserved-1" type = "shortstr" reserved = "1" />
842     </method>
843
844     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
845
846     <method name = "close" synchronous = "1" index = "50" label = "request a connection close">
847       <doc>
848         This method indicates that the sender wants to close the connection. This may be
849         due to internal conditions (e.g. a forced shut-down) or due to an error handling
850         a specific method, i.e. an exception. When a close is due to an exception, the
851         sender provides the class and method id of the method which caused the exception.
852       </doc>
853       <rule name = "stability">
854         <doc>
855           After sending this method, any received methods except Close and Close-OK MUST
856           be discarded.  The response to receiving a Close after sending Close must be to
857           send Close-Ok.
858         </doc>
859       </rule>
860
861       <chassis name = "client" implement = "MUST" />
862       <chassis name = "server" implement = "MUST" />
863       <response name = "close-ok" />
864
865       <field name = "reply-code" domain = "reply-code" />
866       <field name = "reply-text" domain = "reply-text" />
867
868       <field name = "class-id" domain = "class-id" label = "failing method class">
869         <doc>
870           When the close is provoked by a method exception, this is the class of the
871           method.
872         </doc>
873       </field>
874
875       <field name = "method-id" domain = "method-id" label = "failing method ID">
876         <doc>
877           When the close is provoked by a method exception, this is the ID of the method.
878         </doc>
879       </field>
880     </method>
881
882     <method name = "close-ok" synchronous = "1" index = "51" label = "confirm a connection close">
883       <doc>
884         This method confirms a Connection.Close method and tells the recipient that it is
885         safe to release resources for the connection and close the socket.
886       </doc>
887       <rule name = "reporting">
888         <doc>
889           A peer that detects a socket closure without having received a Close-Ok
890           handshake method SHOULD log the error.
891         </doc>
892       </rule>
893       <chassis name = "client" implement = "MUST" />
894       <chassis name = "server" implement = "MUST" />
895     </method>
896   </class>
897
898   <!-- ==  CHANNEL  ========================================================== -->
899
900   <class name = "channel" handler = "channel" index = "20" label = "work with channels">
901     <doc>
902       The channel class provides methods for a client to establish a channel to a
903       server and for both peers to operate the channel thereafter.
904     </doc>
905
906     <doc type = "grammar">
907       channel             = open-channel *use-channel close-channel
908       open-channel        = C:OPEN S:OPEN-OK
909       use-channel         = C:FLOW S:FLOW-OK
910                           / S:FLOW C:FLOW-OK
911                           / functional-class
912       close-channel       = C:CLOSE S:CLOSE-OK
913                           / S:CLOSE C:CLOSE-OK
914     </doc>
915
916     <chassis name = "server" implement = "MUST" />
917     <chassis name = "client" implement = "MUST" />
918
919     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
920
921     <method name = "open" synchronous = "1" index = "10" label = "open a channel for use">
922       <doc>
923         This method opens a channel to the server.
924       </doc>
925       <rule name = "state" on-failure = "channel-error">
926         <doc>
927           The client MUST NOT use this method on an already-opened channel.
928         </doc>
929         <doc type = "scenario">
930           Client opens a channel and then reopens the same channel.
931         </doc>
932       </rule>
933       <chassis name = "server" implement = "MUST" />
934       <response name = "open-ok" />
935       <!-- Deprecated: "out-of-band", must be zero -->
936       <field name = "reserved-1" type = "shortstr" reserved = "1" />
937     </method>
938
939     <method name = "open-ok" synchronous = "1" index = "11" label = "signal that the channel is ready">
940       <doc>
941         This method signals to the client that the channel is ready for use.
942       </doc>
943       <chassis name = "client" implement = "MUST" />
944       <!-- Deprecated: "channel-id", must be zero -->
945       <field name = "reserved-1" type = "longstr" reserved = "1" />
946     </method>
947
948     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
949
950     <method name = "flow" synchronous = "1" index = "20" label = "enable/disable flow from peer">
951       <doc>
952         This method asks the peer to pause or restart the flow of content data sent by
953         a consumer. This is a simple flow-control mechanism that a peer can use to avoid
954         overflowing its queues or otherwise finding itself receiving more messages than
955         it can process. Note that this method is not intended for window control. It does
956         not affect contents returned by Basic.Get-Ok methods.
957       </doc>
958
959       <rule name = "initial-state">
960         <doc>
961           When a new channel is opened, it is active (flow is active). Some applications
962           assume that channels are inactive until started. To emulate this behaviour a
963           client MAY open the channel, then pause it.
964         </doc>
965       </rule>
966
967       <rule name = "bidirectional">
968         <doc>
969           When sending content frames, a peer SHOULD monitor the channel for incoming
970           methods and respond to a Channel.Flow as rapidly as possible.
971         </doc>
972       </rule>
973
974       <rule name = "throttling">
975         <doc>
976           A peer MAY use the Channel.Flow method to throttle incoming content data for
977           internal reasons, for example, when exchanging data over a slower connection.
978         </doc>
979       </rule>
980
981       <rule name = "expected-behaviour">
982         <doc>
983           The peer that requests a Channel.Flow method MAY disconnect and/or ban a peer
984           that does not respect the request.  This is to prevent badly-behaved clients
985           from overwhelming a server.
986         </doc>
987       </rule>
988
989       <chassis name = "server" implement = "MUST" />
990       <chassis name = "client" implement = "MUST" />
991
992       <response name = "flow-ok" />
993
994       <field name = "active" domain = "bit" label = "start/stop content frames">
995         <doc>
996           If 1, the peer starts sending content frames. If 0, the peer stops sending
997           content frames.
998         </doc>
999       </field>
1000     </method>
1001
1002     <method name = "flow-ok" index = "21" label = "confirm a flow method">
1003       <doc>
1004         Confirms to the peer that a flow command was received and processed.
1005       </doc>
1006       <chassis name = "server" implement = "MUST" />
1007       <chassis name = "client" implement = "MUST" />
1008       <field name = "active" domain = "bit" label = "current flow setting">
1009         <doc>
1010           Confirms the setting of the processed flow method: 1 means the peer will start
1011           sending or continue to send content frames; 0 means it will not.
1012         </doc>
1013       </field>
1014     </method>
1015
1016     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
1017
1018     <method name = "close" synchronous = "1" index = "40" label = "request a channel close">
1019       <doc>
1020         This method indicates that the sender wants to close the channel. This may be due to
1021         internal conditions (e.g. a forced shut-down) or due to an error handling a specific
1022         method, i.e. an exception. When a close is due to an exception, the sender provides
1023         the class and method id of the method which caused the exception.
1024       </doc>
1025       <rule name = "stability">
1026         <doc>
1027           After sending this method, any received methods except Close and Close-OK MUST
1028           be discarded.  The response to receiving a Close after sending Close must be to
1029           send Close-Ok.
1030         </doc>
1031       </rule>
1032
1033       <chassis name = "client" implement = "MUST" />
1034       <chassis name = "server" implement = "MUST" />
1035       <response name = "close-ok" />
1036
1037       <field name = "reply-code" domain = "reply-code" />
1038       <field name = "reply-text" domain = "reply-text" />
1039
1040       <field name = "class-id" domain = "class-id" label = "failing method class">
1041         <doc>
1042           When the close is provoked by a method exception, this is the class of the
1043           method.
1044         </doc>
1045       </field>
1046
1047       <field name = "method-id" domain = "method-id" label = "failing method ID">
1048         <doc>
1049           When the close is provoked by a method exception, this is the ID of the method.
1050         </doc>
1051       </field>
1052     </method>
1053
1054     <method name = "close-ok" synchronous = "1" index = "41" label = "confirm a channel close">
1055       <doc>
1056         This method confirms a Channel.Close method and tells the recipient that it is safe
1057         to release resources for the channel.
1058       </doc>
1059       <rule name = "reporting">
1060         <doc>
1061           A peer that detects a socket closure without having received a Channel.Close-Ok
1062           handshake method SHOULD log the error.
1063         </doc>
1064       </rule>
1065       <chassis name = "client" implement = "MUST" />
1066       <chassis name = "server" implement = "MUST" />
1067     </method>
1068   </class>
1069
1070   <!-- ==  EXCHANGE  ========================================================= -->
1071
1072   <class name = "exchange" handler = "channel" index = "40" label = "work with exchanges">
1073     <doc>
1074       Exchanges match and distribute messages across queues. Exchanges can be configured in
1075       the server or declared at runtime.
1076     </doc>
1077
1078     <doc type = "grammar">
1079       exchange            = C:DECLARE  S:DECLARE-OK
1080                           / C:DELETE   S:DELETE-OK
1081                           / C:BIND     S:BIND-OK
1082                           / C:UNBIND   S:UNBIND-OK
1083     </doc>
1084
1085     <chassis name = "server" implement = "MUST" />
1086     <chassis name = "client" implement = "MUST" />
1087
1088     <rule name = "required-types">
1089       <doc>
1090         The server MUST implement these standard exchange types: fanout, direct.
1091       </doc>
1092       <doc type = "scenario">
1093         Client attempts to declare an exchange with each of these standard types.
1094       </doc>
1095     </rule>
1096     <rule name = "recommended-types">
1097       <doc>
1098         The server SHOULD implement these standard exchange types: topic, headers.
1099       </doc>
1100       <doc type = "scenario">
1101         Client attempts to declare an exchange with each of these standard types.
1102       </doc>
1103     </rule>
1104     <rule name = "required-instances">
1105       <doc>
1106         The server MUST, in each virtual host, pre-declare an exchange instance
1107         for each standard exchange type that it implements, where the name of the
1108         exchange instance, if defined, is "amq." followed by the exchange type name.
1109       </doc>
1110       <doc>
1111         The server MUST, in each virtual host, pre-declare at least two direct
1112         exchange instances: one named "amq.direct", the other with no public name
1113         that serves as a default  exchange for Publish methods.
1114       </doc>
1115       <doc type = "scenario">
1116         Client declares a temporary queue and attempts to bind to each required
1117         exchange instance ("amq.fanout", "amq.direct", "amq.topic", and "amq.headers"
1118         if those types are defined).
1119       </doc>
1120     </rule>
1121     <rule name = "default-exchange">
1122       <doc>
1123         The server MUST pre-declare a direct exchange with no public name to act as
1124         the default exchange for content Publish methods and for default queue bindings.
1125       </doc>
1126       <doc type = "scenario">
1127         Client checks that the default exchange is active by specifying a queue
1128         binding with no exchange name, and publishing a message with a suitable
1129         routing key but without specifying the exchange name, then ensuring that
1130         the message arrives in the queue correctly.
1131       </doc>
1132     </rule>
1133     <rule name = "default-access">
1134       <doc>
1135         The server MUST NOT allow clients to access the default exchange except
1136         by specifying an empty exchange name in the Queue.Bind and content Publish
1137         methods.
1138       </doc>
1139     </rule>
1140     <rule name = "extensions">
1141       <doc>
1142         The server MAY implement other exchange types as wanted.
1143       </doc>
1144     </rule>
1145
1146     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
1147
1148     <method name = "declare" synchronous = "1" index = "10" label = "verify exchange exists, create if needed">
1149       <doc>
1150         This method creates an exchange if it does not already exist, and if the exchange
1151         exists, verifies that it is of the correct and expected class.
1152       </doc>
1153       <rule name = "minimum">
1154         <doc>
1155           The server SHOULD support a minimum of 16 exchanges per virtual host and
1156           ideally, impose no limit except as defined by available resources.
1157         </doc>
1158         <doc type = "scenario">
1159           The client declares as many exchanges as it can until the server reports
1160           an error; the number of exchanges successfully declared must be at least
1161           sixteen.
1162         </doc>
1163       </rule>
1164
1165       <chassis name = "server" implement = "MUST" />
1166       <response name = "declare-ok" />
1167
1168       <!-- Deprecated: "ticket", must be zero -->
1169       <field name = "reserved-1" type = "short" reserved = "1" />
1170
1171       <field name = "exchange" domain = "exchange-name">
1172         <rule name = "reserved" on-failure = "access-refused">
1173           <doc>
1174             Exchange names starting with "amq." are reserved for pre-declared and
1175             standardised exchanges. The client MAY declare an exchange starting with
1176             "amq." if the passive option is set, or the exchange already exists.
1177           </doc>
1178           <doc type = "scenario">
1179             The client attempts to declare a non-existing exchange starting with
1180             "amq." and with the passive option set to zero.
1181           </doc>
1182         </rule>
1183         <rule name = "syntax" on-failure = "precondition-failed">
1184           <doc>
1185             The exchange name consists of a non-empty sequence of these characters:
1186             letters, digits, hyphen, underscore, period, or colon.
1187           </doc>
1188           <doc type = "scenario">
1189             The client attempts to declare an exchange with an illegal name.
1190           </doc>
1191         </rule>
1192         <assert check = "notnull" />
1193       </field>
1194
1195       <field name = "type" domain = "shortstr" label = "exchange type">
1196         <doc>
1197           Each exchange belongs to one of a set of exchange types implemented by the
1198           server. The exchange types define the functionality of the exchange - i.e. how
1199           messages are routed through it. It is not valid or meaningful to attempt to
1200           change the type of an existing exchange.
1201         </doc>
1202         <rule name = "typed" on-failure = "not-allowed">
1203           <doc>
1204             Exchanges cannot be redeclared with different types.  The client MUST not
1205             attempt to redeclare an existing exchange with a different type than used
1206             in the original Exchange.Declare method.
1207           </doc>
1208           <doc type = "scenario">
1209             TODO.
1210           </doc>
1211         </rule>
1212         <rule name = "support" on-failure = "command-invalid">
1213           <doc>
1214             The client MUST NOT attempt to declare an exchange with a type that the
1215             server does not support.
1216           </doc>
1217           <doc type = "scenario">
1218             TODO.
1219           </doc>
1220         </rule>
1221       </field>
1222
1223       <field name = "passive" domain = "bit" label = "do not create exchange">
1224         <doc>
1225           If set, the server will reply with Declare-Ok if the exchange already
1226           exists with the same name, and raise an error if not.  The client can
1227           use this to check whether an exchange exists without modifying the
1228           server state. When set, all other method fields except name and no-wait
1229           are ignored.  A declare with both passive and no-wait has no effect.
1230           Arguments are compared for semantic equivalence.
1231         </doc>
1232         <rule name = "not-found">
1233           <doc>
1234             If set, and the exchange does not already exist, the server MUST
1235             raise a channel exception with reply code 404 (not found).
1236           </doc>
1237           <doc type = "scenario">
1238             TODO.
1239           </doc>
1240         </rule>
1241         <rule name = "equivalent">
1242           <doc>
1243             If not set and the exchange exists, the server MUST check that the
1244             existing exchange has the same values for type, durable, and arguments
1245             fields.  The server MUST respond with Declare-Ok if the requested
1246             exchange matches these fields, and MUST raise a channel exception if
1247             not.
1248           </doc>
1249           <doc type = "scenario">
1250             TODO.
1251           </doc>
1252         </rule>
1253       </field>
1254
1255       <field name = "durable" domain = "bit" label = "request a durable exchange">
1256         <doc>
1257           If set when creating a new exchange, the exchange will be marked as durable.
1258           Durable exchanges remain active when a server restarts. Non-durable exchanges
1259           (transient exchanges) are purged if/when a server restarts.
1260         </doc>
1261         <rule name = "support">
1262           <doc>
1263             The server MUST support both durable and transient exchanges.
1264           </doc>
1265           <doc type = "scenario">
1266             TODO.
1267           </doc>
1268         </rule>
1269       </field>
1270
1271       <field name = "auto-delete" domain = "bit" label = "auto-delete when unused">
1272         <doc>
1273           If set, the exchange is deleted when all queues have
1274           finished using it.
1275         </doc>
1276         <rule name = "amq_exchange_02">
1277           <doc>
1278             The server SHOULD allow for a reasonable delay between the
1279             point when it determines that an exchange is not being
1280             used (or no longer used), and the point when it deletes
1281             the exchange.  At the least it must allow a client to
1282             create an exchange and then bind a queue to it, with a
1283             small but non-zero delay between these two actions.
1284           </doc>
1285         </rule>
1286         <rule name = "amq_exchange_25">
1287           <doc>
1288             The server MUST ignore the auto-delete field if the
1289             exchange already exists.
1290           </doc>
1291         </rule>
1292       </field>
1293
1294       <field name = "internal" domain = "bit" label = "create internal exchange">
1295         <doc>
1296           If set, the exchange may not be used directly by publishers,
1297           but only when bound to other exchanges. Internal exchanges
1298           are used to construct wiring that is not visible to
1299           applications.
1300         </doc>
1301       </field>
1302
1303       <field name = "no-wait" domain = "no-wait" />
1304
1305       <field name = "arguments" domain = "table" label = "arguments for declaration">
1306         <doc>
1307           A set of arguments for the declaration. The syntax and semantics of these
1308           arguments depends on the server implementation.
1309         </doc>
1310       </field>
1311     </method>
1312
1313     <method name = "declare-ok" synchronous = "1" index = "11" label = "confirm exchange declaration">
1314       <doc>
1315         This method confirms a Declare method and confirms the name of the exchange,
1316         essential for automatically-named exchanges.
1317       </doc>
1318       <chassis name = "client" implement = "MUST" />
1319     </method>
1320
1321     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
1322
1323     <method name = "delete" synchronous = "1" index = "20" label = "delete an exchange">
1324       <doc>
1325         This method deletes an exchange. When an exchange is deleted all queue bindings on
1326         the exchange are cancelled.
1327       </doc>
1328
1329       <chassis name = "server" implement = "MUST" />
1330       <response name = "delete-ok" />
1331
1332       <!-- Deprecated: "ticket", must be zero -->
1333       <field name = "reserved-1" type = "short" reserved = "1" />
1334
1335       <field name = "exchange" domain = "exchange-name">
1336         <rule name = "exists" on-failure = "not-found">
1337           <doc>
1338             The client MUST NOT attempt to delete an exchange that does not exist.
1339           </doc>
1340         </rule>
1341         <assert check = "notnull" />
1342       </field>
1343
1344       <field name = "if-unused" domain = "bit" label = "delete only if unused">
1345         <doc>
1346           If set, the server will only delete the exchange if it has no queue bindings. If
1347           the exchange has queue bindings the server does not delete it but raises a
1348           channel exception instead.
1349         </doc>
1350         <rule name = "in-use" on-failure = "precondition-failed">
1351           <doc>
1352             The server MUST NOT delete an exchange that has bindings on it, if the if-unused
1353             field is true.
1354           </doc>
1355           <doc type = "scenario">
1356             The client declares an exchange, binds a queue to it, then tries to delete it
1357             setting if-unused to true.
1358           </doc>
1359         </rule>
1360       </field>
1361
1362       <field name = "no-wait" domain = "no-wait" />
1363     </method>
1364
1365     <method name = "delete-ok" synchronous = "1" index = "21"
1366       label = "confirm deletion of an exchange">
1367       <doc>This method confirms the deletion of an exchange.</doc>
1368       <chassis name = "client" implement = "MUST" />
1369     </method>
1370
1371     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
1372
1373     <method name = "bind" synchronous = "1" index = "30"
1374             label = "bind exchange to an exchange">
1375
1376       <doc>This method binds an exchange to an exchange.</doc>
1377
1378       <rule name = "duplicates">
1379         <doc>
1380           A server MUST allow and ignore duplicate bindings - that is,
1381           two or more bind methods for a specific exchanges, with
1382           identical arguments - without treating these as an error.
1383         </doc>
1384         <doc type = "scenario">
1385           A client binds an exchange to an exchange. The client then
1386           repeats the bind (with identical arguments).
1387         </doc>
1388       </rule>
1389
1390       <rule name = "cyclical">
1391         <doc>
1392           A server MUST allow cycles of exchange bindings to be
1393           created including allowing an exchange to be bound to
1394           itself.
1395         </doc>
1396         <doc type = "scenario">
1397           A client declares an exchange and binds it to itself.
1398         </doc>
1399       </rule>
1400
1401       <rule name = "unique">
1402         <doc>
1403           A server MUST not deliver the same message more than once to
1404           a destination exchange, even if the topology of exchanges
1405           and bindings results in multiple (even infinite) routes to
1406           that exchange.
1407         </doc>
1408         <doc type = "scenario">
1409           A client declares an exchange and binds it using multiple
1410           bindings to the amq.topic exchange. The client then
1411           publishes a message to the amq.topic exchange that matches
1412           all the bindings.
1413         </doc>
1414       </rule>
1415
1416       <chassis name = "server" implement = "MUST"/>
1417
1418       <response name = "bind-ok"/>
1419
1420       <!-- Deprecated: "ticket", must be zero -->
1421       <field name = "reserved-1" type = "short" reserved = "1"/>
1422
1423       <field name = "destination" domain = "exchange-name"
1424              label = "name of the destination exchange to bind to">
1425         <doc>Specifies the name of the destination exchange to bind.</doc>
1426         <rule name = "exchange-existence" on-failure = "not-found">
1427           <doc>
1428             A client MUST NOT be allowed to bind a non-existent
1429             destination exchange.
1430           </doc>
1431           <doc type = "scenario">
1432             A client attempts to bind an undeclared exchange to an
1433             exchange.
1434           </doc>
1435         </rule>
1436         <rule name = "default-exchange">
1437           <doc>
1438             The server MUST accept a blank exchange name to mean the
1439             default exchange.
1440           </doc>
1441           <doc type = "scenario">
1442             The client declares an exchange and binds a blank exchange
1443             name to it.
1444           </doc>
1445         </rule>
1446       </field>
1447
1448       <field name = "source" domain = "exchange-name"
1449              label = "name of the source exchange to bind to">
1450         <doc>Specifies the name of the source exchange to bind.</doc>
1451         <rule name = "exchange-existence" on-failure = "not-found">
1452           <doc>
1453             A client MUST NOT be allowed to bind a non-existent source
1454             exchange.
1455           </doc>
1456           <doc type = "scenario">
1457             A client attempts to bind an exchange to an undeclared
1458             exchange.
1459           </doc>
1460         </rule>
1461         <rule name = "default-exchange">
1462           <doc>
1463             The server MUST accept a blank exchange name to mean the
1464             default exchange.
1465           </doc>
1466           <doc type = "scenario">
1467             The client declares an exchange and binds it to a blank
1468             exchange name.
1469           </doc>
1470         </rule>
1471       </field>
1472
1473       <field name = "routing-key" domain = "shortstr"
1474              label = "message routing key">
1475         <doc>
1476           Specifies the routing key for the binding. The routing key
1477           is used for routing messages depending on the exchange
1478           configuration. Not all exchanges use a routing key - refer
1479           to the specific exchange documentation.
1480         </doc>
1481       </field>
1482
1483       <field name = "no-wait" domain = "no-wait"/>
1484
1485       <field name = "arguments" domain = "table"
1486              label = "arguments for binding">
1487         <doc>
1488           A set of arguments for the binding. The syntax and semantics
1489           of these arguments depends on the exchange class.
1490         </doc>
1491       </field>
1492     </method>
1493
1494     <method name="bind-ok" synchronous="1" index="31"
1495             label = "confirm bind successful">
1496       <doc>This method confirms that the bind was successful.</doc>
1497
1498       <chassis name="client" implement="MUST"/>
1499     </method>
1500
1501     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
1502
1503     <method name = "unbind" synchronous = "1" index = "40"
1504             label = "unbind an exchange from an exchange">
1505       <doc>This method unbinds an exchange from an exchange.</doc>
1506       <rule name = "01">
1507         <doc>If a unbind fails, the server MUST raise a connection exception.</doc>
1508       </rule>
1509       <chassis name = "server" implement = "MUST"/>
1510       <response name = "unbind-ok"/>
1511
1512       <!-- Deprecated: "ticket", must be zero -->
1513       <field name = "reserved-1" type = "short" reserved = "1"/>
1514
1515       <field name = "destination" domain = "exchange-name">
1516         <doc>Specifies the name of the destination exchange to unbind.</doc>
1517         <rule name = "must-exist" on-failure = "not-found">
1518           <doc>
1519             The client MUST NOT attempt to unbind an exchange that
1520             does not exist from an exchange.
1521           </doc>
1522           <doc type = "scenario">
1523             The client attempts to unbind a non-existent exchange from
1524             an exchange.
1525           </doc>
1526         </rule>
1527         <rule name = "default-exchange">
1528           <doc>
1529             The server MUST accept a blank exchange name to mean the
1530             default exchange.
1531           </doc>
1532           <doc type = "scenario">
1533             The client declares an exchange, binds a blank exchange
1534             name to it, and then unbinds a blank exchange name from
1535             it.
1536           </doc>
1537         </rule>
1538       </field>
1539
1540       <field name = "source" domain = "exchange-name">
1541         <doc>Specifies the name of the source exchange to unbind.</doc>
1542         <rule name = "must-exist" on-failure = "not-found">
1543           <doc>
1544             The client MUST NOT attempt to unbind an exchange from an
1545             exchange that does not exist.
1546           </doc>
1547           <doc type = "scenario">
1548             The client attempts to unbind an exchange from a
1549             non-existent exchange.
1550           </doc>
1551         </rule>
1552         <rule name = "default-exchange">
1553           <doc>
1554             The server MUST accept a blank exchange name to mean the
1555             default exchange.
1556           </doc>
1557           <doc type = "scenario">
1558             The client declares an exchange, binds an exchange to a
1559             blank exchange name, and then unbinds an exchange from a
1560             black exchange name.
1561           </doc>
1562         </rule>
1563       </field>
1564
1565       <field name = "routing-key" domain = "shortstr"
1566              label = "routing key of binding">
1567         <doc>Specifies the routing key of the binding to unbind.</doc>
1568       </field>
1569
1570       <field name = "no-wait" domain = "no-wait"/>
1571
1572       <field name = "arguments" domain = "table"
1573              label = "arguments of binding">
1574         <doc>Specifies the arguments of the binding to unbind.</doc>
1575       </field>
1576     </method>
1577
1578     <method name = "unbind-ok" synchronous = "1" index = "51"
1579             label = "confirm unbind successful">
1580       <doc>This method confirms that the unbind was successful.</doc>
1581       <chassis name = "client" implement = "MUST"/>
1582     </method>
1583
1584   </class>
1585
1586   <!-- ==  QUEUE  ============================================================ -->
1587
1588   <class name = "queue" handler = "channel" index = "50" label = "work with queues">
1589     <doc>
1590       Queues store and forward messages. Queues can be configured in the server or created at
1591       runtime. Queues must be attached to at least one exchange in order to receive messages
1592       from publishers.
1593     </doc>
1594
1595     <doc type = "grammar">
1596       queue               = C:DECLARE  S:DECLARE-OK
1597                           / C:BIND     S:BIND-OK
1598                           / C:UNBIND   S:UNBIND-OK
1599                           / C:PURGE    S:PURGE-OK
1600                           / C:DELETE   S:DELETE-OK
1601     </doc>
1602
1603     <chassis name = "server" implement = "MUST" />
1604     <chassis name = "client" implement = "MUST" />
1605
1606     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
1607
1608     <method name = "declare" synchronous = "1" index = "10" label = "declare queue, create if needed">
1609       <doc>
1610         This method creates or checks a queue. When creating a new queue the client can
1611         specify various properties that control the durability of the queue and its
1612         contents, and the level of sharing for the queue.
1613       </doc>
1614
1615       <rule name = "default-binding">
1616         <doc>
1617           The server MUST create a default binding for a newly-declared queue to the
1618           default exchange, which is an exchange of type 'direct' and use the queue
1619           name as the routing key.
1620         </doc>
1621         <doc type = "scenario">
1622           Client declares a new queue, and then without explicitly binding it to an
1623           exchange, attempts to send a message through the default exchange binding,
1624           i.e. publish a message to the empty exchange, with the queue name as routing
1625           key.
1626         </doc>
1627       </rule>
1628
1629       <rule name = "minimum-queues">
1630         <doc>
1631           The server SHOULD support a minimum of 256 queues per virtual host and ideally,
1632           impose no limit except as defined by available resources.
1633         </doc>
1634         <doc type = "scenario">
1635           Client attempts to declare as many queues as it can until the server reports
1636           an error.  The resulting count must at least be 256.
1637         </doc>
1638       </rule>
1639
1640       <chassis name = "server" implement = "MUST" />
1641       <response name = "declare-ok" />
1642
1643       <!-- Deprecated: "ticket", must be zero -->
1644       <field name = "reserved-1" type = "short" reserved = "1" />
1645
1646       <field name = "queue" domain = "queue-name">
1647         <rule name = "default-name">
1648           <doc>
1649             The queue name MAY be empty, in which case the server MUST create a new
1650             queue with a unique generated name and return this to the client in the
1651             Declare-Ok method.
1652           </doc>
1653           <doc type = "scenario">
1654             Client attempts to declare several queues with an empty name. The client then
1655             verifies that the server-assigned names are unique and different.
1656           </doc>
1657         </rule>
1658         <rule name = "reserved" on-failure = "access-refused">
1659           <doc>
1660             Queue names starting with "amq." are reserved for pre-declared and
1661             standardised queues. The client MAY declare a queue starting with
1662             "amq." if the passive option is set, or the queue already exists.
1663           </doc>
1664           <doc type = "scenario">
1665             The client attempts to declare a non-existing queue starting with
1666             "amq." and with the passive option set to zero.
1667           </doc>
1668         </rule>
1669         <rule name = "syntax" on-failure = "precondition-failed">
1670           <doc>
1671             The queue name can be empty, or a sequence of these characters:
1672             letters, digits, hyphen, underscore, period, or colon.
1673           </doc>
1674           <doc type = "scenario">
1675             The client attempts to declare a queue with an illegal name.
1676           </doc>
1677         </rule>
1678       </field>
1679
1680       <field name = "passive" domain = "bit" label = "do not create queue">
1681         <doc>
1682           If set, the server will reply with Declare-Ok if the queue already
1683           exists with the same name, and raise an error if not.  The client can
1684           use this to check whether a queue exists without modifying the
1685           server state.  When set, all other method fields except name and no-wait
1686           are ignored.  A declare with both passive and no-wait has no effect.
1687           Arguments are compared for semantic equivalence.
1688         </doc>
1689         <rule name = "passive" on-failure = "not-found">
1690           <doc>
1691             The client MAY ask the server to assert that a queue exists without
1692             creating the queue if not.  If the queue does not exist, the server
1693             treats this as a failure.
1694           </doc>
1695           <doc type = "scenario">
1696             Client declares an existing queue with the passive option and expects
1697             the server to respond with a declare-ok. Client then attempts to declare
1698             a non-existent queue with the passive option, and the server must close
1699             the channel with the correct reply-code.
1700           </doc>
1701         </rule>
1702         <rule name = "equivalent">
1703           <doc>
1704             If not set and the queue exists, the server MUST check that the
1705             existing queue has the same values for durable, exclusive, auto-delete,
1706             and arguments fields.  The server MUST respond with Declare-Ok if the
1707             requested queue matches these fields, and MUST raise a channel exception
1708             if not.
1709           </doc>
1710           <doc type = "scenario">
1711             TODO.
1712           </doc>
1713         </rule>
1714       </field>
1715
1716       <field name = "durable" domain = "bit" label = "request a durable queue">
1717         <doc>
1718           If set when creating a new queue, the queue will be marked as durable. Durable
1719           queues remain active when a server restarts. Non-durable queues (transient
1720           queues) are purged if/when a server restarts. Note that durable queues do not
1721           necessarily hold persistent messages, although it does not make sense to send
1722           persistent messages to a transient queue.
1723         </doc>
1724
1725         <rule name = "persistence">
1726           <doc>The server MUST recreate the durable queue after a restart.</doc>
1727
1728           <doc type = "scenario">
1729             Client declares a durable queue. The server is then restarted. The client
1730             then attempts to send a message to the queue. The message should be successfully
1731             delivered.
1732           </doc>
1733         </rule>
1734
1735         <rule name = "types">
1736           <doc>The server MUST support both durable and transient queues.</doc>
1737           <doc type = "scenario">
1738             A client declares two named queues, one durable and one transient.
1739           </doc>
1740         </rule>
1741       </field>
1742
1743       <field name = "exclusive" domain = "bit" label = "request an exclusive queue">
1744         <doc>
1745           Exclusive queues may only be accessed by the current connection, and are
1746           deleted when that connection closes.  Passive declaration of an exclusive
1747           queue by other connections are not allowed.
1748         </doc>
1749
1750         <rule name = "types">
1751           <doc>
1752             The server MUST support both exclusive (private) and non-exclusive (shared)
1753             queues.
1754           </doc>
1755           <doc type = "scenario">
1756             A client declares two named queues, one exclusive and one non-exclusive.
1757           </doc>
1758         </rule>
1759
1760         <rule name = "exclusive" on-failure = "resource-locked">
1761           <doc>
1762             The client MAY NOT attempt to use a queue that was declared as exclusive
1763             by another still-open connection.
1764           </doc>
1765           <doc type = "scenario">
1766             One client declares an exclusive queue. A second client on a different
1767             connection attempts to declare, bind, consume, purge, delete, or declare
1768             a queue of the same name.
1769           </doc>
1770         </rule>
1771       </field>
1772
1773       <field name = "auto-delete" domain = "bit" label = "auto-delete queue when unused">
1774         <doc>
1775           If set, the queue is deleted when all consumers have finished using it.  The last
1776           consumer can be cancelled either explicitly or because its channel is closed. If
1777           there was no consumer ever on the queue, it won't be deleted.  Applications can
1778           explicitly delete auto-delete queues using the Delete method as normal.
1779         </doc>
1780
1781         <rule name = "pre-existence">
1782           <doc>
1783             The server MUST ignore the auto-delete field if the queue already exists.
1784           </doc>
1785           <doc type = "scenario">
1786             Client declares two named queues, one as auto-delete and one explicit-delete.
1787             Client then attempts to declare the two queues using the same names again,
1788             but reversing the value of the auto-delete field in each case. Verify that the
1789             queues still exist with the original auto-delete flag values.
1790           </doc>
1791         </rule>
1792       </field>
1793
1794       <field name = "no-wait" domain = "no-wait" />
1795
1796       <field name = "arguments" domain = "table" label = "arguments for declaration">
1797         <doc>
1798           A set of arguments for the declaration. The syntax and semantics of these
1799           arguments depends on the server implementation.
1800         </doc>
1801       </field>
1802     </method>
1803
1804     <method name = "declare-ok" synchronous = "1" index = "11" label = "confirms a queue definition">
1805       <doc>
1806         This method confirms a Declare method and confirms the name of the queue, essential
1807         for automatically-named queues.
1808       </doc>
1809
1810       <chassis name = "client" implement = "MUST" />
1811
1812       <field name = "queue" domain = "queue-name">
1813         <doc>
1814           Reports the name of the queue. If the server generated a queue name, this field
1815           contains that name.
1816         </doc>
1817         <assert check = "notnull" />
1818       </field>
1819
1820       <field name = "message-count" domain = "message-count" />
1821
1822       <field name = "consumer-count" domain = "long" label = "number of consumers">
1823         <doc>
1824           Reports the number of active consumers for the queue. Note that consumers can
1825           suspend activity (Channel.Flow) in which case they do not appear in this count.
1826         </doc>
1827       </field>
1828     </method>
1829
1830     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
1831
1832     <method name = "bind" synchronous = "1" index = "20" label = "bind queue to an exchange">
1833       <doc>
1834         This method binds a queue to an exchange. Until a queue is bound it will not
1835         receive any messages. In a classic messaging model, store-and-forward queues
1836         are bound to a direct exchange and subscription queues are bound to a topic
1837         exchange.
1838       </doc>
1839
1840       <rule name = "duplicates">
1841         <doc>
1842           A server MUST allow ignore duplicate bindings - that is, two or more bind
1843           methods for a specific queue, with identical arguments - without treating these
1844           as an error.
1845         </doc>
1846         <doc type = "scenario">
1847           A client binds a named queue to an exchange. The client then repeats the bind
1848           (with identical arguments).
1849         </doc>
1850       </rule>
1851
1852       <rule name = "unique">
1853         <doc>
1854           A server MUST not deliver the same message more than once to a queue, even if
1855           the queue has multiple bindings that match the message.
1856         </doc>
1857         <doc type = "scenario">
1858           A client declares a named queue and binds it using multiple bindings to the
1859           amq.topic exchange. The client then publishes a message that matches all its
1860           bindings.
1861         </doc>
1862       </rule>
1863
1864       <rule name = "transient-exchange">
1865         <doc>
1866           The server MUST allow a durable queue to bind to a transient exchange.
1867         </doc>
1868         <doc type = "scenario">
1869           A client declares a transient exchange. The client then declares a named durable
1870           queue and then attempts to bind the transient exchange to the durable queue.
1871         </doc>
1872       </rule>
1873
1874       <rule name = "durable-exchange">
1875         <doc>
1876           Bindings of durable queues to durable exchanges are automatically durable
1877           and the server MUST restore such bindings after a server restart.
1878         </doc>
1879         <doc type = "scenario">
1880           A server declares a named durable queue and binds it to a durable exchange. The
1881           server is restarted. The client then attempts to use the queue/exchange combination.
1882         </doc>
1883       </rule>
1884
1885       <rule name = "binding-count">
1886         <doc>
1887           The server SHOULD support at least 4 bindings per queue, and ideally, impose no
1888           limit except as defined by available resources.
1889         </doc>
1890         <doc type = "scenario">
1891           A client declares a named queue and attempts to bind it to 4 different
1892           exchanges.
1893         </doc>
1894       </rule>
1895
1896       <chassis name = "server" implement = "MUST" />
1897
1898       <response name = "bind-ok" />
1899
1900       <!-- Deprecated: "ticket", must be zero -->
1901       <field name = "reserved-1" type = "short" reserved = "1" />
1902
1903       <field name = "queue" domain = "queue-name">
1904         <doc>Specifies the name of the queue to bind.</doc>
1905         <rule name = "queue-known" on-failure = "not-found">
1906           <doc>
1907             The client MUST either specify a queue name or have previously declared a
1908             queue on the same channel
1909           </doc>
1910           <doc type = "scenario">
1911             The client opens a channel and attempts to bind an unnamed queue.
1912           </doc>
1913         </rule>
1914         <rule name = "must-exist" on-failure = "not-found">
1915           <doc>
1916             The client MUST NOT attempt to bind a queue that does not exist.
1917           </doc>
1918           <doc type = "scenario">
1919             The client attempts to bind a non-existent queue.
1920           </doc>
1921         </rule>
1922       </field>
1923
1924       <field name = "exchange" domain = "exchange-name" label = "name of the exchange to bind to">
1925         <rule name = "exchange-existence" on-failure = "not-found">
1926           <doc>
1927             A client MUST NOT be allowed to bind a queue to a non-existent exchange.
1928           </doc>
1929           <doc type = "scenario">
1930             A client attempts to bind an named queue to a undeclared exchange.
1931           </doc>
1932         </rule>
1933         <rule name = "default-exchange">
1934           <doc>
1935             The server MUST accept a blank exchange name to mean the default exchange.
1936           </doc>
1937           <doc type = "scenario">
1938             The client declares a queue and binds it to a blank exchange name.
1939           </doc>
1940         </rule>
1941       </field>
1942
1943       <field name = "routing-key" domain = "shortstr" label = "message routing key">
1944         <doc>
1945           Specifies the routing key for the binding. The routing key is used for routing
1946           messages depending on the exchange configuration. Not all exchanges use a
1947           routing key - refer to the specific exchange documentation.  If the queue name
1948           is empty, the server uses the last queue declared on the channel.  If the
1949           routing key is also empty, the server uses this queue name for the routing
1950           key as well.  If the queue name is provided but the routing key is empty, the
1951           server does the binding with that empty routing key.  The meaning of empty
1952           routing keys depends on the exchange implementation.
1953         </doc>
1954         <rule name = "direct-exchange-key-matching">
1955           <doc>
1956             If a message queue binds to a direct exchange using routing key K and a
1957             publisher sends the exchange a message with routing key R, then the message
1958             MUST be passed to the message queue if K = R.
1959           </doc>
1960         </rule>
1961       </field>
1962
1963       <field name = "no-wait" domain = "no-wait" />
1964
1965       <field name = "arguments" domain = "table" label = "arguments for binding">
1966         <doc>
1967           A set of arguments for the binding. The syntax and semantics of these arguments
1968           depends on the exchange class.
1969         </doc>
1970       </field>
1971     </method>
1972
1973     <method name = "bind-ok" synchronous = "1" index = "21" label = "confirm bind successful">
1974       <doc>This method confirms that the bind was successful.</doc>
1975
1976       <chassis name = "client" implement = "MUST" />
1977     </method>
1978
1979     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
1980
1981     <method name = "unbind" synchronous = "1" index = "50" label = "unbind a queue from an exchange">
1982       <doc>This method unbinds a queue from an exchange.</doc>
1983       <rule name = "01">
1984         <doc>If a unbind fails, the server MUST raise a connection exception.</doc>
1985       </rule>
1986       <chassis name="server" implement="MUST"/>
1987       <response name="unbind-ok"/>
1988
1989       <!-- Deprecated: "ticket", must be zero -->
1990       <field name = "reserved-1" type = "short" reserved = "1" />
1991
1992       <field name = "queue" domain = "queue-name">
1993         <doc>Specifies the name of the queue to unbind.</doc>
1994         <rule name = "queue-known" on-failure = "not-found">
1995           <doc>
1996             The client MUST either specify a queue name or have previously declared a
1997             queue on the same channel
1998           </doc>
1999           <doc type = "scenario">
2000             The client opens a channel and attempts to unbind an unnamed queue.
2001           </doc>
2002         </rule>
2003         <rule name = "must-exist" on-failure = "not-found">
2004           <doc>
2005             The client MUST NOT attempt to unbind a queue that does not exist.
2006           </doc>
2007           <doc type = "scenario">
2008             The client attempts to unbind a non-existent queue.
2009           </doc>
2010         </rule>
2011       </field>
2012
2013       <field name = "exchange" domain = "exchange-name">
2014         <doc>The name of the exchange to unbind from.</doc>
2015         <rule name = "must-exist" on-failure = "not-found">
2016           <doc>
2017             The client MUST NOT attempt to unbind a queue from an exchange that
2018             does not exist.
2019           </doc>
2020           <doc type = "scenario">
2021             The client attempts to unbind a queue from a non-existent exchange.
2022           </doc>
2023         </rule>
2024         <rule name = "default-exchange">
2025           <doc>
2026             The server MUST accept a blank exchange name to mean the default exchange.
2027           </doc>
2028           <doc type = "scenario">
2029             The client declares a queue and binds it to a blank exchange name.
2030           </doc>
2031         </rule>
2032       </field>
2033
2034       <field name = "routing-key" domain = "shortstr" label = "routing key of binding">
2035         <doc>Specifies the routing key of the binding to unbind.</doc>
2036       </field>
2037
2038       <field name = "arguments" domain = "table" label = "arguments of binding">
2039         <doc>Specifies the arguments of the binding to unbind.</doc>
2040       </field>
2041     </method>
2042
2043     <method name = "unbind-ok" synchronous = "1" index = "51" label = "confirm unbind successful">
2044       <doc>This method confirms that the unbind was successful.</doc>
2045       <chassis name = "client" implement = "MUST"/>
2046     </method>
2047
2048     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2049
2050     <method name = "purge" synchronous = "1" index = "30" label = "purge a queue">
2051       <doc>
2052         This method removes all messages from a queue which are not awaiting
2053         acknowledgment.
2054       </doc>
2055
2056       <rule name = "02">
2057         <doc>
2058           The server MUST NOT purge messages that have already been sent to a client
2059           but not yet acknowledged.
2060         </doc>
2061       </rule>
2062
2063       <rule name = "03">
2064         <doc>
2065           The server MAY implement a purge queue or log that allows system administrators
2066           to recover accidentally-purged messages. The server SHOULD NOT keep purged
2067           messages in the same storage spaces as the live messages since the volumes of
2068           purged messages may get very large.
2069         </doc>
2070       </rule>
2071
2072       <chassis name = "server" implement = "MUST" />
2073
2074       <response name = "purge-ok" />
2075
2076       <!-- Deprecated: "ticket", must be zero -->
2077       <field name = "reserved-1" type = "short" reserved = "1" />
2078
2079       <field name = "queue" domain = "queue-name">
2080         <doc>Specifies the name of the queue to purge.</doc>
2081         <rule name = "queue-known" on-failure = "not-found">
2082           <doc>
2083             The client MUST either specify a queue name or have previously declared a
2084             queue on the same channel
2085           </doc>
2086           <doc type = "scenario">
2087             The client opens a channel and attempts to purge an unnamed queue.
2088           </doc>
2089         </rule>
2090         <rule name = "must-exist" on-failure = "not-found">
2091           <doc>
2092             The client MUST NOT attempt to purge a queue that does not exist.
2093           </doc>
2094           <doc type = "scenario">
2095             The client attempts to purge a non-existent queue.
2096           </doc>
2097         </rule>
2098       </field>
2099
2100       <field name = "no-wait" domain = "no-wait" />
2101     </method>
2102
2103     <method name = "purge-ok" synchronous = "1" index = "31" label = "confirms a queue purge">
2104       <doc>This method confirms the purge of a queue.</doc>
2105
2106       <chassis name = "client" implement = "MUST" />
2107
2108       <field name = "message-count" domain = "message-count">
2109         <doc>
2110           Reports the number of messages purged.
2111         </doc>
2112       </field>
2113     </method>
2114
2115     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2116
2117     <method name = "delete" synchronous = "1" index = "40" label = "delete a queue">
2118       <doc>
2119         This method deletes a queue. When a queue is deleted any pending messages are sent
2120         to a dead-letter queue if this is defined in the server configuration, and all
2121         consumers on the queue are cancelled.
2122       </doc>
2123
2124       <rule name = "01">
2125         <doc>
2126           The server SHOULD use a dead-letter queue to hold messages that were pending on
2127           a deleted queue, and MAY provide facilities for a system administrator to move
2128           these messages back to an active queue.
2129         </doc>
2130       </rule>
2131
2132       <chassis name = "server" implement = "MUST" />
2133
2134       <response name = "delete-ok" />
2135
2136       <!-- Deprecated: "ticket", must be zero -->
2137       <field name = "reserved-1" type = "short" reserved = "1" />
2138
2139       <field name = "queue" domain = "queue-name">
2140         <doc>Specifies the name of the queue to delete.</doc>
2141         <rule name = "queue-known" on-failure = "not-found">
2142           <doc>
2143             The client MUST either specify a queue name or have previously declared a
2144             queue on the same channel
2145           </doc>
2146           <doc type = "scenario">
2147             The client opens a channel and attempts to delete an unnamed queue.
2148           </doc>
2149         </rule>
2150         <rule name = "must-exist" on-failure = "not-found">
2151           <doc>
2152             The client MUST NOT attempt to delete a queue that does not exist.
2153           </doc>
2154           <doc type = "scenario">
2155             The client attempts to delete a non-existent queue.
2156           </doc>
2157         </rule>
2158       </field>
2159
2160       <field name = "if-unused" domain = "bit" label = "delete only if unused">
2161         <doc>
2162           If set, the server will only delete the queue if it has no consumers. If the
2163           queue has consumers the server does does not delete it but raises a channel
2164           exception instead.
2165         </doc>
2166         <rule name = "in-use" on-failure = "precondition-failed">
2167           <doc>
2168             The server MUST NOT delete a queue that has consumers on it, if the if-unused
2169             field is true.
2170           </doc>
2171           <doc type = "scenario">
2172             The client declares a queue, and consumes from it, then tries to delete it
2173             setting if-unused to true.
2174           </doc>
2175         </rule>
2176       </field>
2177
2178       <field name = "if-empty" domain = "bit" label = "delete only if empty">
2179         <doc>
2180           If set, the server will only delete the queue if it has no messages.
2181         </doc>
2182         <rule name = "not-empty" on-failure = "precondition-failed">
2183           <doc>
2184             The server MUST NOT delete a queue that has messages on it, if the
2185             if-empty field is true.
2186           </doc>
2187           <doc type = "scenario">
2188             The client declares a queue, binds it and publishes some messages into it,
2189             then tries to delete it setting if-empty to true.
2190           </doc>
2191         </rule>
2192       </field>
2193
2194       <field name = "no-wait" domain = "no-wait" />
2195     </method>
2196
2197     <method name = "delete-ok" synchronous = "1" index = "41" label = "confirm deletion of a queue">
2198       <doc>This method confirms the deletion of a queue.</doc>
2199
2200       <chassis name = "client" implement = "MUST" />
2201
2202       <field name = "message-count" domain = "message-count">
2203         <doc>Reports the number of messages deleted.</doc>
2204       </field>
2205     </method>
2206   </class>
2207
2208   <!-- ==  BASIC  ============================================================ -->
2209
2210   <class name = "basic" handler = "channel" index = "60" label = "work with basic content">
2211     <doc>
2212       The Basic class provides methods that support an industry-standard messaging model.
2213     </doc>
2214
2215     <doc type = "grammar">
2216       basic               = C:QOS S:QOS-OK
2217                           / C:CONSUME S:CONSUME-OK
2218                           / C:CANCEL S:CANCEL-OK
2219                           / C:PUBLISH content
2220                           / S:RETURN content
2221                           / S:DELIVER content
2222                           / C:GET ( S:GET-OK content / S:GET-EMPTY )
2223                           / C:ACK
2224                           / S:ACK
2225                           / C:REJECT
2226                           / C:NACK
2227                           / S:NACK
2228                           / C:RECOVER-ASYNC
2229                           / C:RECOVER S:RECOVER-OK
2230     </doc>
2231
2232     <chassis name = "server" implement = "MUST" />
2233     <chassis name = "client" implement = "MAY" />
2234
2235     <rule name = "01">
2236       <doc>
2237         The server SHOULD respect the persistent property of basic messages and
2238         SHOULD make a best-effort to hold persistent basic messages on a reliable
2239         storage mechanism.
2240       </doc>
2241       <doc type = "scenario">
2242         Send a persistent message to queue, stop server, restart server and then
2243         verify whether message is still present.  Assumes that queues are durable.
2244         Persistence without durable queues makes no sense.
2245       </doc>
2246     </rule>
2247
2248     <rule name = "02">
2249       <doc>
2250         The server MUST NOT discard a persistent basic message in case of a queue
2251         overflow.
2252       </doc>
2253       <doc type = "scenario">
2254         Declare a queue overflow situation with persistent messages and verify that
2255         messages do not get lost (presumably the server will write them to disk).
2256       </doc>
2257     </rule>
2258
2259     <rule name = "03">
2260       <doc>
2261         The server MAY use the Channel.Flow method to slow or stop a basic message
2262         publisher when necessary.
2263       </doc>
2264       <doc type = "scenario">
2265         Declare a queue overflow situation with non-persistent messages and verify
2266         whether the server responds with Channel.Flow or not. Repeat with persistent
2267         messages.
2268       </doc>
2269     </rule>
2270
2271     <rule name = "04">
2272       <doc>
2273         The server MAY overflow non-persistent basic messages to persistent
2274         storage.
2275       </doc>
2276       <!-- Test scenario: untestable -->
2277     </rule>
2278
2279     <rule name = "05">
2280       <doc>
2281         The server MAY discard or dead-letter non-persistent basic messages on a
2282         priority basis if the queue size exceeds some configured limit.
2283       </doc>
2284       <!-- Test scenario: untestable -->
2285     </rule>
2286
2287     <rule name = "06">
2288       <doc>
2289         The server MUST implement at least 2 priority levels for basic messages,
2290         where priorities 0-4 and 5-9 are treated as two distinct levels.
2291       </doc>
2292       <doc type = "scenario">
2293         Send a number of priority 0 messages to a queue. Send one priority 9
2294         message.  Consume messages from the queue and verify that the first message
2295         received was priority 9.
2296       </doc>
2297     </rule>
2298
2299     <rule name = "07">
2300       <doc>
2301         The server MAY implement up to 10 priority levels.
2302       </doc>
2303       <doc type = "scenario">
2304         Send a number of messages with mixed priorities to a queue, so that all
2305         priority values from 0 to 9 are exercised. A good scenario would be ten
2306         messages in low-to-high priority.  Consume from queue and verify how many
2307         priority levels emerge.
2308       </doc>
2309     </rule>
2310
2311     <rule name = "08">
2312       <doc>
2313         The server MUST deliver messages of the same priority in order irrespective of
2314         their individual persistence.
2315       </doc>
2316       <doc type = "scenario">
2317         Send a set of messages with the same priority but different persistence
2318         settings to a queue.  Consume and verify that messages arrive in same order
2319         as originally published.
2320       </doc>
2321     </rule>
2322
2323     <rule name = "09">
2324       <doc>
2325         The server MUST support un-acknowledged delivery of Basic content, i.e.
2326         consumers with the no-ack field set to TRUE.
2327       </doc>
2328     </rule>
2329
2330     <rule name = "10">
2331       <doc>
2332         The server MUST support explicitly acknowledged delivery of Basic content,
2333         i.e. consumers with the no-ack field set to FALSE.
2334       </doc>
2335       <doc type = "scenario">
2336         Declare a queue and a consumer using explicit acknowledgements.  Publish a
2337         set of messages to the queue.  Consume the messages but acknowledge only
2338         half of them.  Disconnect and reconnect, and consume from the queue.
2339         Verify that the remaining messages are received.
2340       </doc>
2341     </rule>
2342
2343     <!--  These are the properties for a Basic content  -->
2344
2345     <!--  MIME typing -->
2346     <field name = "content-type"    domain = "shortstr"   label = "MIME content type" />
2347     <!--  MIME typing -->
2348     <field name = "content-encoding" domain = "shortstr"  label = "MIME content encoding" />
2349     <!--  For applications, and for header exchange routing -->
2350     <field name = "headers"         domain = "table"      label = "message header field table" />
2351     <!--  For queues that implement persistence -->
2352     <field name = "delivery-mode"   domain = "octet"      label = "non-persistent (1) or persistent (2)" />
2353     <!--  For queues that implement priorities -->
2354     <field name = "priority"        domain = "octet"      label = "message priority, 0 to 9" />
2355     <!--  For application use, no formal behaviour -->
2356     <field name = "correlation-id"  domain = "shortstr"   label = "application correlation identifier" />
2357     <!--  For application use, no formal behaviour but may hold the
2358           name of a private response queue, when used in request messages -->
2359     <field name = "reply-to"        domain = "shortstr"   label = "address to reply to" />
2360     <!--  For implementation use, no formal behaviour -->
2361     <field name = "expiration"      domain = "shortstr"   label = "message expiration specification" />
2362     <!--  For application use, no formal behaviour -->
2363     <field name = "message-id"      domain = "shortstr"   label = "application message identifier" />
2364     <!--  For application use, no formal behaviour -->
2365     <field name = "timestamp"       domain = "timestamp"  label = "message timestamp" />
2366     <!--  For application use, no formal behaviour -->
2367     <field name = "type"            domain = "shortstr"   label = "message type name" />
2368     <!--  For application use, no formal behaviour -->
2369     <field name = "user-id"         domain = "shortstr"   label = "creating user id" />
2370     <!--  For application use, no formal behaviour -->
2371     <field name = "app-id"          domain = "shortstr"   label = "creating application id" />
2372     <!--  Deprecated, was old cluster-id property -->
2373     <field name = "reserved"        domain = "shortstr"   label = "reserved, must be empty" />
2374
2375     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2376
2377     <method name = "qos" synchronous = "1" index = "10" label = "specify quality of service">
2378       <doc>
2379         This method requests a specific quality of service. The QoS can be specified for the
2380         current channel or for all channels on the connection. The particular properties and
2381         semantics of a qos method always depend on the content class semantics. Though the
2382         qos method could in principle apply to both peers, it is currently meaningful only
2383         for the server.
2384       </doc>
2385
2386       <chassis name = "server" implement = "MUST" />
2387       <response name = "qos-ok" />
2388
2389       <field name = "prefetch-size" domain = "long" label = "prefetch window in octets">
2390         <doc>
2391           The client can request that messages be sent in advance so that when the client
2392           finishes processing a message, the following message is already held locally,
2393           rather than needing to be sent down the channel. Prefetching gives a performance
2394           improvement. This field specifies the prefetch window size in octets. The server
2395           will send a message in advance if it is equal to or smaller in size than the
2396           available prefetch size (and also falls into other prefetch limits). May be set
2397           to zero, meaning "no specific limit", although other prefetch limits may still
2398           apply. The prefetch-size is ignored if the no-ack option is set.
2399         </doc>
2400         <rule name = "01">
2401           <doc>
2402             The server MUST ignore this setting when the client is not processing any
2403             messages - i.e. the prefetch size does not limit the transfer of single
2404             messages to a client, only the sending in advance of more messages while
2405             the client still has one or more unacknowledged messages.
2406           </doc>
2407           <doc type = "scenario">
2408             Define a QoS prefetch-size limit and send a single message that exceeds
2409             that limit.  Verify that the message arrives correctly.
2410           </doc>
2411         </rule>
2412       </field>
2413
2414       <field name = "prefetch-count" domain = "short" label = "prefetch window in messages">
2415         <doc>
2416           Specifies a prefetch window in terms of whole messages. This field may be used
2417           in combination with the prefetch-size field; a message will only be sent in
2418           advance if both prefetch windows (and those at the channel and connection level)
2419           allow it. The prefetch-count is ignored if the no-ack option is set.
2420         </doc>
2421         <rule name = "01">
2422           <doc>
2423             The server may send less data in advance than allowed by the client's
2424             specified prefetch windows but it MUST NOT send more.
2425           </doc>
2426           <doc type = "scenario">
2427             Define a QoS prefetch-size limit and a prefetch-count limit greater than
2428             one.  Send multiple messages that exceed the prefetch size.  Verify that
2429             no more than one message arrives at once.
2430           </doc>
2431         </rule>
2432       </field>
2433
2434       <field name = "global" domain = "bit" label = "apply to entire connection">
2435         <doc>
2436           By default the QoS settings apply to the current channel only. If this field is
2437           set, they are applied to the entire connection.
2438         </doc>
2439       </field>
2440     </method>
2441
2442     <method name = "qos-ok" synchronous = "1" index = "11" label = "confirm the requested qos">
2443       <doc>
2444         This method tells the client that the requested QoS levels could be handled by the
2445         server. The requested QoS applies to all active consumers until a new QoS is
2446         defined.
2447       </doc>
2448       <chassis name = "client" implement = "MUST" />
2449     </method>
2450
2451     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2452
2453     <method name = "consume" synchronous = "1" index = "20" label = "start a queue consumer">
2454       <doc>
2455         This method asks the server to start a "consumer", which is a transient request for
2456         messages from a specific queue. Consumers last as long as the channel they were
2457         declared on, or until the client cancels them.
2458       </doc>
2459
2460       <rule name = "01">
2461         <doc>
2462           The server SHOULD support at least 16 consumers per queue, and ideally, impose
2463           no limit except as defined by available resources.
2464         </doc>
2465         <doc type = "scenario">
2466           Declare a queue and create consumers on that queue until the server closes the
2467           connection. Verify that the number of consumers created was at least sixteen
2468           and report the total number.
2469         </doc>
2470       </rule>
2471
2472       <chassis name = "server" implement = "MUST" />
2473       <response name = "consume-ok" />
2474
2475       <!-- Deprecated: "ticket", must be zero -->
2476       <field name = "reserved-1" type = "short" reserved = "1" />
2477
2478       <field name = "queue" domain = "queue-name">
2479         <doc>Specifies the name of the queue to consume from.</doc>
2480       </field>
2481
2482       <field name = "consumer-tag" domain = "consumer-tag">
2483         <doc>
2484           Specifies the identifier for the consumer. The consumer tag is local to a
2485           channel, so two clients can use the same consumer tags. If this field is
2486           empty the server will generate a unique tag.
2487         </doc>
2488         <rule name = "01" on-failure = "not-allowed">
2489           <doc>
2490             The client MUST NOT specify a tag that refers to an existing consumer.
2491           </doc>
2492           <doc type = "scenario">
2493             Attempt to create two consumers with the same non-empty tag, on the
2494             same channel.
2495           </doc>
2496         </rule>
2497         <rule name = "02" on-failure = "not-allowed">
2498           <doc>
2499             The consumer tag is valid only within the channel from which the
2500             consumer was created. I.e. a client MUST NOT create a consumer in one
2501             channel and then use it in another.
2502           </doc>
2503           <doc type = "scenario">
2504             Attempt to create a consumer in one channel, then use in another channel,
2505             in which consumers have also been created (to test that the server uses
2506             unique consumer tags).
2507           </doc>
2508         </rule>
2509       </field>
2510
2511       <field name = "no-local" domain = "no-local" />
2512
2513       <field name = "no-ack" domain = "no-ack" />
2514
2515       <field name = "exclusive" domain = "bit" label = "request exclusive access">
2516         <doc>
2517           Request exclusive consumer access, meaning only this consumer can access the
2518           queue.
2519         </doc>
2520
2521         <rule name = "01" on-failure = "access-refused">
2522           <doc>
2523             The client MAY NOT gain exclusive access to a queue that already has
2524             active consumers.
2525           </doc>
2526           <doc type = "scenario">
2527             Open two connections to a server, and in one connection declare a shared
2528             (non-exclusive) queue and then consume from the queue.  In the second
2529             connection attempt to consume from the same queue using the exclusive
2530             option.
2531           </doc>
2532         </rule>
2533       </field>
2534
2535       <field name = "no-wait" domain = "no-wait" />
2536
2537       <field name = "arguments" domain = "table" label = "arguments for declaration">
2538         <doc>
2539           A set of arguments for the consume. The syntax and semantics of these
2540           arguments depends on the server implementation.
2541         </doc>
2542       </field>
2543     </method>
2544
2545     <method name = "consume-ok" synchronous = "1" index = "21" label = "confirm a new consumer">
2546       <doc>
2547         The server provides the client with a consumer tag, which is used by the client
2548         for methods called on the consumer at a later stage.
2549       </doc>
2550       <chassis name = "client" implement = "MUST" />
2551       <field name = "consumer-tag" domain = "consumer-tag">
2552         <doc>
2553           Holds the consumer tag specified by the client or provided by the server.
2554         </doc>
2555       </field>
2556     </method>
2557
2558     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2559
2560     <method name = "cancel" synchronous = "1" index = "30" label = "end a queue consumer">
2561       <doc>
2562         This method cancels a consumer. This does not affect already delivered
2563         messages, but it does mean the server will not send any more messages for
2564         that consumer. The client may receive an arbitrary number of messages in
2565         between sending the cancel method and receiving the cancel-ok reply.
2566
2567         It may also be sent from the server to the client in the event
2568         of the consumer being unexpectedly cancelled (i.e. cancelled
2569         for any reason other than the server receiving the
2570         corresponding basic.cancel from the client). This allows
2571         clients to be notified of the loss of consumers due to events
2572         such as queue deletion. Note that as it is not a MUST for
2573         clients to accept this method from the client, it is advisable
2574         for the broker to be able to identify those clients that are
2575         capable of accepting the method, through some means of
2576         capability negotiation.
2577       </doc>
2578
2579       <rule name = "01">
2580         <doc>
2581           If the queue does not exist the server MUST ignore the cancel method, so
2582           long as the consumer tag is valid for that channel.
2583         </doc>
2584         <doc type = "scenario">
2585           TODO.
2586         </doc>
2587       </rule>
2588
2589       <chassis name = "server" implement = "MUST" />
2590       <chassis name = "client" implement = "SHOULD" />
2591       <response name = "cancel-ok" />
2592
2593       <field name = "consumer-tag" domain = "consumer-tag" />
2594       <field name = "no-wait" domain = "no-wait" />
2595     </method>
2596
2597     <method name = "cancel-ok" synchronous = "1" index = "31" label = "confirm a cancelled consumer">
2598       <doc>
2599         This method confirms that the cancellation was completed.
2600       </doc>
2601       <chassis name = "client" implement = "MUST" />
2602       <chassis name = "server" implement = "MAY" />
2603       <field name = "consumer-tag" domain = "consumer-tag" />
2604     </method>
2605
2606     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2607
2608     <method name = "publish" content = "1" index = "40" label = "publish a message">
2609       <doc>
2610         This method publishes a message to a specific exchange. The message will be routed
2611         to queues as defined by the exchange configuration and distributed to any active
2612         consumers when the transaction, if any, is committed.
2613       </doc>
2614
2615       <chassis name = "server" implement = "MUST" />
2616
2617       <!-- Deprecated: "ticket", must be zero -->
2618       <field name = "reserved-1" type = "short" reserved = "1" />
2619
2620       <field name = "exchange" domain = "exchange-name">
2621         <doc>
2622           Specifies the name of the exchange to publish to. The exchange name can be
2623           empty, meaning the default exchange. If the exchange name is specified, and that
2624           exchange does not exist, the server will raise a channel exception.
2625         </doc>
2626
2627         <rule name = "must-exist" on-failure = "not-found">
2628           <doc>
2629             The client MUST NOT attempt to publish a content to an exchange that
2630             does not exist.
2631           </doc>
2632           <doc type = "scenario">
2633             The client attempts to publish a content to a non-existent exchange.
2634           </doc>
2635         </rule>
2636         <rule name = "default-exchange">
2637           <doc>
2638             The server MUST accept a blank exchange name to mean the default exchange.
2639           </doc>
2640           <doc type = "scenario">
2641             The client declares a queue and binds it to a blank exchange name.
2642           </doc>
2643         </rule>
2644         <rule name = "02">
2645           <doc>
2646             If the exchange was declared as an internal exchange, the server MUST raise
2647             a channel exception with a reply code 403 (access refused).
2648           </doc>
2649           <doc type = "scenario">
2650             TODO.
2651           </doc>
2652         </rule>
2653
2654         <rule name = "03">
2655           <doc>
2656             The exchange MAY refuse basic content in which case it MUST raise a channel
2657             exception with reply code 540 (not implemented).
2658           </doc>
2659           <doc type = "scenario">
2660             TODO.
2661           </doc>
2662         </rule>
2663       </field>
2664
2665       <field name = "routing-key" domain = "shortstr" label = "Message routing key">
2666         <doc>
2667           Specifies the routing key for the message. The routing key is used for routing
2668           messages depending on the exchange configuration.
2669         </doc>
2670       </field>
2671
2672       <field name = "mandatory" domain = "bit" label = "indicate mandatory routing">
2673         <doc>
2674           This flag tells the server how to react if the message cannot be routed to a
2675           queue. If this flag is set, the server will return an unroutable message with a
2676           Return method. If this flag is zero, the server silently drops the message.
2677         </doc>
2678
2679         <rule name = "01">
2680           <doc>
2681             The server SHOULD implement the mandatory flag.
2682           </doc>
2683           <doc type = "scenario">
2684             TODO.
2685           </doc>
2686         </rule>
2687       </field>
2688
2689       <field name = "immediate" domain = "bit" label = "request immediate delivery">
2690         <doc>
2691           This flag tells the server how to react if the message cannot be routed to a
2692           queue consumer immediately. If this flag is set, the server will return an
2693           undeliverable message with a Return method. If this flag is zero, the server
2694           will queue the message, but with no guarantee that it will ever be consumed.
2695         </doc>
2696
2697         <rule name = "01">
2698           <doc>
2699             The server SHOULD implement the immediate flag.
2700           </doc>
2701           <doc type = "scenario">
2702             TODO.
2703           </doc>
2704         </rule>
2705       </field>
2706     </method>
2707
2708     <method name = "return" content = "1" index = "50" label = "return a failed message">
2709       <doc>
2710         This method returns an undeliverable message that was published with the "immediate"
2711         flag set, or an unroutable message published with the "mandatory" flag set. The
2712         reply code and text provide information about the reason that the message was
2713         undeliverable.
2714       </doc>
2715
2716       <chassis name = "client" implement = "MUST" />
2717
2718       <field name = "reply-code" domain = "reply-code" />
2719       <field name = "reply-text" domain = "reply-text" />
2720
2721       <field name = "exchange" domain = "exchange-name">
2722         <doc>
2723           Specifies the name of the exchange that the message was originally published
2724           to.  May be empty, meaning the default exchange.
2725         </doc>
2726       </field>
2727
2728       <field name = "routing-key" domain = "shortstr" label = "Message routing key">
2729         <doc>
2730           Specifies the routing key name specified when the message was published.
2731         </doc>
2732       </field>
2733     </method>
2734
2735     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2736
2737     <method name = "deliver" content = "1" index = "60"
2738       label = "notify the client of a consumer message">
2739       <doc>
2740         This method delivers a message to the client, via a consumer. In the asynchronous
2741         message delivery model, the client starts a consumer using the Consume method, then
2742         the server responds with Deliver methods as and when messages arrive for that
2743         consumer.
2744       </doc>
2745
2746       <rule name = "01">
2747         <doc>
2748           The server SHOULD track the number of times a message has been delivered to
2749           clients and when a message is redelivered a certain number of times - e.g. 5
2750           times - without being acknowledged, the server SHOULD consider the message to be
2751           unprocessable (possibly causing client applications to abort), and move the
2752           message to a dead letter queue.
2753         </doc>
2754         <doc type = "scenario">
2755           TODO.
2756         </doc>
2757       </rule>
2758
2759       <chassis name = "client" implement = "MUST" />
2760
2761       <field name = "consumer-tag" domain = "consumer-tag" />
2762       <field name = "delivery-tag" domain = "delivery-tag" />
2763       <field name = "redelivered" domain = "redelivered" />
2764
2765       <field name = "exchange" domain = "exchange-name">
2766         <doc>
2767           Specifies the name of the exchange that the message was originally published to.
2768           May be empty, indicating the default exchange.
2769         </doc>
2770       </field>
2771
2772       <field name = "routing-key" domain = "shortstr" label = "Message routing key">
2773         <doc>Specifies the routing key name specified when the message was published.</doc>
2774       </field>
2775     </method>
2776
2777     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2778
2779     <method name = "get" synchronous = "1" index = "70" label = "direct access to a queue">
2780       <doc>
2781         This method provides a direct access to the messages in a queue using a synchronous
2782         dialogue that is designed for specific types of application where synchronous
2783         functionality is more important than performance.
2784       </doc>
2785
2786       <response name = "get-ok" />
2787       <response name = "get-empty" />
2788       <chassis name = "server" implement = "MUST" />
2789
2790       <!-- Deprecated: "ticket", must be zero -->
2791       <field name = "reserved-1" type = "short" reserved = "1" />
2792
2793       <field name = "queue" domain = "queue-name">
2794         <doc>Specifies the name of the queue to get a message from.</doc>
2795       </field>
2796       <field name = "no-ack" domain = "no-ack" />
2797     </method>
2798
2799     <method name = "get-ok" synchronous = "1" content = "1" index = "71"
2800       label = "provide client with a message">
2801       <doc>
2802         This method delivers a message to the client following a get method. A message
2803         delivered by 'get-ok' must be acknowledged unless the no-ack option was set in the
2804         get method.
2805       </doc>
2806
2807       <chassis name = "client" implement = "MAY" />
2808
2809       <field name = "delivery-tag" domain = "delivery-tag" />
2810       <field name = "redelivered" domain = "redelivered" />
2811       <field name = "exchange" domain = "exchange-name">
2812         <doc>
2813           Specifies the name of the exchange that the message was originally published to.
2814           If empty, the message was published to the default exchange.
2815         </doc>
2816       </field>
2817
2818       <field name = "routing-key" domain = "shortstr" label = "Message routing key">
2819         <doc>Specifies the routing key name specified when the message was published.</doc>
2820       </field>
2821
2822       <field name = "message-count" domain = "message-count" />
2823     </method>
2824
2825     <method name = "get-empty" synchronous = "1" index = "72"
2826       label = "indicate no messages available">
2827       <doc>
2828         This method tells the client that the queue has no messages available for the
2829         client.
2830       </doc>
2831       <chassis name = "client" implement = "MAY" />
2832       <!-- Deprecated: "cluster-id", must be empty -->
2833       <field name = "reserved-1" type = "shortstr" reserved = "1" />
2834     </method>
2835
2836     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2837
2838     <method name = "ack" index = "80" label = "acknowledge one or more messages">
2839       <doc>
2840         When sent by the client, this method acknowledges one or more
2841         messages delivered via the Deliver or Get-Ok methods.
2842
2843         When sent by server, this method acknowledges one or more
2844         messages published with the Publish method on a channel in
2845         confirm mode.
2846
2847         The acknowledgement can be for a single message or a set of
2848         messages up to and including a specific message.
2849       </doc>
2850
2851       <chassis name = "server" implement = "MUST" />
2852       <chassis name ="client" implement = "MUST"/>
2853
2854       <field name = "delivery-tag" domain = "delivery-tag" />
2855       <field name = "multiple" domain = "bit" label = "acknowledge multiple messages">
2856         <doc>
2857           If set to 1, the delivery tag is treated as "up to and
2858           including", so that multiple messages can be acknowledged
2859           with a single method. If set to zero, the delivery tag
2860           refers to a single message. If the multiple field is 1, and
2861           the delivery tag is zero, this indicates acknowledgement of
2862           all outstanding messages.
2863         </doc>
2864         <rule name = "exists" on-failure = "precondition-failed">
2865           <doc>
2866             A message MUST not be acknowledged more than once.  The
2867             receiving peer MUST validate that a non-zero delivery-tag
2868             refers to a delivered message, and raise a channel
2869             exception if this is not the case. On a transacted
2870             channel, this check MUST be done immediately and not
2871             delayed until a Tx.Commit.
2872           </doc>
2873           <doc type = "scenario">
2874             TODO.
2875           </doc>
2876         </rule>
2877       </field>
2878     </method>
2879
2880     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2881
2882     <method name = "reject" index = "90" label = "reject an incoming message">
2883       <doc>
2884         This method allows a client to reject a message. It can be used to interrupt and
2885         cancel large incoming messages, or return untreatable messages to their original
2886         queue.
2887       </doc>
2888
2889       <rule name = "01">
2890         <doc>
2891           The server SHOULD be capable of accepting and process the Reject method while
2892           sending message content with a Deliver or Get-Ok method. I.e. the server should
2893           read and process incoming methods while sending output frames. To cancel a
2894           partially-send content, the server sends a content body frame of size 1 (i.e.
2895           with no data except the frame-end octet).
2896         </doc>
2897       </rule>
2898
2899       <rule name = "02">
2900         <doc>
2901           The server SHOULD interpret this method as meaning that the client is unable to
2902           process the message at this time.
2903         </doc>
2904         <doc type = "scenario">
2905           TODO.
2906         </doc>
2907       </rule>
2908
2909       <rule name = "03">
2910         <doc>
2911           The client MUST NOT use this method as a means of selecting messages to process.
2912         </doc>
2913         <doc type = "scenario">
2914           TODO.
2915         </doc>
2916       </rule>
2917
2918       <chassis name = "server" implement = "MUST" />
2919
2920       <field name = "delivery-tag" domain = "delivery-tag" />
2921
2922       <field name = "requeue" domain = "bit" label = "requeue the message">
2923         <doc>
2924           If requeue is true, the server will attempt to requeue the message.  If requeue
2925           is false or the requeue  attempt fails the messages are discarded or dead-lettered.
2926         </doc>
2927
2928         <rule name = "01">
2929           <doc>
2930             The server MUST NOT deliver the message to the same client within the
2931             context of the current channel. The recommended strategy is to attempt to
2932             deliver the message to an alternative consumer, and if that is not possible,
2933             to move the message to a dead-letter queue. The server MAY use more
2934             sophisticated tracking to hold the message on the queue and redeliver it to
2935             the same client at a later stage.
2936           </doc>
2937           <doc type = "scenario">
2938             TODO.
2939           </doc>
2940         </rule>
2941       </field>
2942     </method>
2943
2944     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2945
2946     <method name = "recover-async" index = "100" label = "redeliver unacknowledged messages"
2947         deprecated = "1">
2948       <doc>
2949         This method asks the server to redeliver all unacknowledged messages on a
2950         specified channel. Zero or more messages may be redelivered.  This method
2951         is deprecated in favour of the synchronous Recover/Recover-Ok.
2952       </doc>
2953       <rule name = "01">
2954         <doc>
2955           The server MUST set the redelivered flag on all messages that are resent.
2956         </doc>
2957         <doc type = "scenario">
2958           TODO.
2959         </doc>
2960       </rule>
2961       <chassis name = "server" implement = "MAY" />
2962       <field name = "requeue" domain = "bit" label = "requeue the message">
2963         <doc>
2964           If this field is zero, the message will be redelivered to the original
2965           recipient. If this bit is 1, the server will attempt to requeue the message,
2966           potentially then delivering it to an alternative subscriber.
2967         </doc>
2968       </field>
2969     </method>
2970
2971     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
2972
2973     <method name = "recover" index = "110" label = "redeliver unacknowledged messages">
2974       <doc>
2975         This method asks the server to redeliver all unacknowledged messages on a
2976         specified channel. Zero or more messages may be redelivered.  This method
2977         replaces the asynchronous Recover.
2978       </doc>
2979       <rule name = "01">
2980         <doc>
2981           The server MUST set the redelivered flag on all messages that are resent.
2982         </doc>
2983         <doc type = "scenario">
2984           TODO.
2985         </doc>
2986       </rule>
2987       <chassis name = "server" implement = "MUST" />
2988       <field name = "requeue" domain = "bit" label = "requeue the message">
2989         <doc>
2990           If this field is zero, the message will be redelivered to the original
2991           recipient. If this bit is 1, the server will attempt to requeue the message,
2992           potentially then delivering it to an alternative subscriber.
2993         </doc>
2994       </field>
2995     </method>
2996
2997     <method name = "recover-ok" synchronous = "1" index = "111" label = "confirm recovery">
2998       <doc>
2999         This method acknowledges a Basic.Recover method.
3000       </doc>
3001       <chassis name = "client" implement = "MUST" />
3002     </method>
3003
3004     <method name = "nack" index = "120" label = "reject one or more incoming messages">
3005       <doc>
3006         This method allows a client to reject one or more incoming messages. It can be
3007         used to interrupt and cancel large incoming messages, or return untreatable
3008         messages to their original queue.
3009
3010         This method is also used by the server to inform publishers on channels in
3011         confirm mode of unhandled messages.  If a publisher receives this method, it
3012         probably needs to republish the offending messages.
3013       </doc>
3014
3015       <rule name = "01">
3016         <doc>
3017           The server SHOULD be capable of accepting and processing the Nack method while
3018           sending message content with a Deliver or Get-Ok method. I.e. the server should
3019           read and process incoming methods while sending output frames. To cancel a
3020           partially-send content, the server sends a content body frame of size 1 (i.e.
3021           with no data except the frame-end octet).
3022         </doc>
3023       </rule>
3024
3025       <rule name = "02">
3026         <doc>
3027           The server SHOULD interpret this method as meaning that the client is unable to
3028           process the message at this time.
3029         </doc>
3030         <doc type = "scenario">
3031           TODO.
3032         </doc>
3033       </rule>
3034
3035       <rule name = "03">
3036         <doc>
3037           The client MUST NOT use this method as a means of selecting messages to process.
3038         </doc>
3039         <doc type = "scenario">
3040           TODO.
3041         </doc>
3042       </rule>
3043
3044       <rule name = "04">
3045         <doc>
3046           A client publishing messages to a channel in confirm mode SHOULD be capable of accepting
3047           and somehow handling the Nack method.
3048         </doc>
3049         <doc type = "scenario">
3050           TODO
3051         </doc>
3052       </rule>
3053
3054       <chassis name = "server" implement = "MUST" />
3055       <chassis name = "client" implement = "MUST" />
3056
3057       <field name = "delivery-tag" domain = "delivery-tag" />
3058
3059       <field name = "multiple" domain = "bit" label = "reject multiple messages">
3060         <doc>
3061           If set to 1, the delivery tag is treated as "up to and
3062           including", so that multiple messages can be rejected
3063           with a single method. If set to zero, the delivery tag
3064           refers to a single message. If the multiple field is 1, and
3065           the delivery tag is zero, this indicates rejection of
3066           all outstanding messages.
3067         </doc>
3068         <rule name = "exists" on-failure = "precondition-failed">
3069           <doc>
3070             A message MUST not be rejected more than once.  The
3071             receiving peer MUST validate that a non-zero delivery-tag
3072             refers to an unacknowledged, delivered message, and
3073             raise a channel exception if this is not the case.
3074           </doc>
3075           <doc type = "scenario">
3076             TODO.
3077           </doc>
3078         </rule>
3079       </field>
3080
3081       <field name = "requeue" domain = "bit" label = "requeue the message">
3082         <doc>
3083           If requeue is true, the server will attempt to requeue the message.  If requeue
3084           is false or the requeue  attempt fails the messages are discarded or dead-lettered.
3085           Clients receiving the Nack methods should ignore this flag.
3086         </doc>
3087
3088         <rule name = "01">
3089           <doc>
3090             The server MUST NOT deliver the message to the same client within the
3091             context of the current channel. The recommended strategy is to attempt to
3092             deliver the message to an alternative consumer, and if that is not possible,
3093             to move the message to a dead-letter queue. The server MAY use more
3094             sophisticated tracking to hold the message on the queue and redeliver it to
3095             the same client at a later stage.
3096           </doc>
3097           <doc type = "scenario">
3098             TODO.
3099           </doc>
3100         </rule>
3101       </field>
3102     </method>
3103
3104   </class>
3105
3106   <!-- ==  TX  =============================================================== -->
3107
3108   <class name = "tx" handler = "channel" index = "90" label = "work with transactions">
3109     <doc>
3110       The Tx class allows publish and ack operations to be batched into atomic
3111       units of work.  The intention is that all publish and ack requests issued
3112       within a transaction will complete successfully or none of them will.
3113       Servers SHOULD implement atomic transactions at least where all publish
3114       or ack requests affect a single queue.  Transactions that cover multiple
3115       queues may be non-atomic, given that queues can be created and destroyed
3116       asynchronously, and such events do not form part of any transaction.
3117       Further, the behaviour of transactions with respect to the immediate and
3118       mandatory flags on Basic.Publish methods is not defined.
3119     </doc>
3120
3121     <rule name = "not multiple queues">
3122       <doc>
3123       Applications MUST NOT rely on the atomicity of transactions that
3124       affect more than one queue.
3125       </doc>
3126     </rule>
3127     <rule name = "not immediate">
3128       <doc>
3129       Applications MUST NOT rely on the behaviour of transactions that
3130       include messages published with the immediate option.
3131       </doc>
3132     </rule>
3133     <rule name = "not mandatory">
3134       <doc>
3135       Applications MUST NOT rely on the behaviour of transactions that
3136       include messages published with the mandatory option.
3137       </doc>
3138     </rule>
3139
3140     <doc type = "grammar">
3141       tx                  = C:SELECT S:SELECT-OK
3142                           / C:COMMIT S:COMMIT-OK
3143                           / C:ROLLBACK S:ROLLBACK-OK
3144     </doc>
3145
3146     <chassis name = "server" implement = "SHOULD" />
3147     <chassis name = "client" implement = "MAY" />
3148
3149     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
3150
3151     <method name = "select" synchronous = "1" index = "10" label = "select standard transaction mode">
3152       <doc>
3153         This method sets the channel to use standard transactions. The client must use this
3154         method at least once on a channel before using the Commit or Rollback methods.
3155       </doc>
3156       <chassis name = "server" implement = "MUST" />
3157       <response name = "select-ok" />
3158     </method>
3159
3160     <method name = "select-ok" synchronous = "1" index = "11" label = "confirm transaction mode">
3161       <doc>
3162         This method confirms to the client that the channel was successfully set to use
3163         standard transactions.
3164       </doc>
3165       <chassis name = "client" implement = "MUST" />
3166     </method>
3167
3168     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
3169
3170     <method name = "commit" synchronous = "1" index = "20" label = "commit the current transaction">
3171       <doc>
3172         This method commits all message publications and acknowledgments performed in
3173         the current transaction.  A new transaction starts immediately after a commit.
3174       </doc>
3175       <chassis name = "server" implement = "MUST" />
3176       <response name = "commit-ok" />
3177
3178       <rule name = "transacted" on-failure = "precondition-failed">
3179         <doc>
3180           The client MUST NOT use the Commit method on non-transacted channels.
3181         </doc>
3182         <doc type = "scenario">
3183           The client opens a channel and then uses Tx.Commit.
3184         </doc>
3185       </rule>
3186     </method>
3187
3188     <method name = "commit-ok" synchronous = "1" index = "21" label = "confirm a successful commit">
3189       <doc>
3190         This method confirms to the client that the commit succeeded. Note that if a commit
3191         fails, the server raises a channel exception.
3192       </doc>
3193       <chassis name = "client" implement = "MUST" />
3194     </method>
3195
3196     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
3197
3198     <method name = "rollback" synchronous = "1" index = "30"
3199       label = "abandon the current transaction">
3200       <doc>
3201         This method abandons all message publications and acknowledgments performed in
3202         the current transaction. A new transaction starts immediately after a rollback.
3203         Note that unacked messages will not be automatically redelivered by rollback;
3204         if that is required an explicit recover call should be issued.
3205       </doc>
3206       <chassis name = "server" implement = "MUST" />
3207       <response name = "rollback-ok" />
3208
3209       <rule name = "transacted" on-failure = "precondition-failed">
3210         <doc>
3211           The client MUST NOT use the Rollback method on non-transacted channels.
3212         </doc>
3213         <doc type = "scenario">
3214           The client opens a channel and then uses Tx.Rollback.
3215         </doc>
3216       </rule>
3217     </method>
3218
3219     <method name = "rollback-ok" synchronous = "1" index = "31" label = "confirm successful rollback">
3220       <doc>
3221         This method confirms to the client that the rollback succeeded. Note that if an
3222         rollback fails, the server raises a channel exception.
3223       </doc>
3224       <chassis name = "client" implement = "MUST" />
3225     </method>
3226   </class>
3227
3228   <!-- ==  CONFIRM  ========================================================== -->
3229
3230   <class name = "confirm" handler = "channel" index = "85" label = "work with confirms">
3231     <doc>
3232       The Confirm class allows publishers to put the channel in
3233       confirm mode and susequently be notified when messages have been
3234       handled by the broker.  The intention is that all messages
3235       published on a channel in confirm mode will be acknowledged at
3236       some point.  By acknowledging a message the broker assumes
3237       responsibility for it and indicates that it has done something
3238       it deems reasonable with it.
3239
3240       Unroutable mandatory or immediate messages are acknowledged
3241       right after the Basic.Return method. Messages are acknowledged
3242       when all queues to which the message has been routed
3243       have either delivered the message and received an
3244       acknowledgement (if required), or enqueued the message (and
3245       persisted it if required).
3246
3247       Published messages are assigned ascending sequence numbers,
3248       starting at 1 with the first Confirm.Select method. The server
3249       confirms messages by sending Basic.Ack methods referring to these
3250       sequence numbers.
3251     </doc>
3252
3253     <rule name = "all messages acknowledged">
3254       <doc>
3255         The server MUST acknowledge all messages received after the
3256         channel was put into confirm mode.
3257       </doc>
3258     </rule>
3259
3260     <rule name = "all queues">
3261       <doc>
3262         The server MUST acknowledge a message only after it was
3263         properly handled by all the queues it was delivered to.
3264       </doc>
3265     </rule>
3266
3267     <rule name = "unroutable messages">
3268       <doc>
3269         The server MUST acknowledge an unroutable mandatory or
3270         immediate message only after it sends the Basic.Return.
3271       </doc>
3272     </rule>
3273
3274     <rule name = "time guarantees">
3275       <doc>
3276         No guarantees are made as to how soon a message is
3277         acknowledged.  Applications SHOULD NOT make assumptions about
3278         this.
3279       </doc>
3280     </rule>
3281
3282     <doc type = "grammar">
3283       confirm            = C:SELECT S:SELECT-OK
3284     </doc>
3285
3286     <chassis name = "server" implement = "SHOULD" />
3287     <chassis name = "client" implement = "MAY" />
3288
3289     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
3290
3291     <method name="select" synchronous="1" index="10">
3292       select confirm mode (i.e. enable publisher acknowledgements)
3293       <doc>
3294         This method sets the channel to use publisher acknowledgements.
3295         The client can only use this method on a non-transactional
3296         channel.
3297       </doc>
3298       <chassis name="server" implement="MUST"/>
3299       <response name="select-ok"/>
3300       <field name = "nowait" type = "bit">
3301         do not send a reply method
3302         <doc>
3303           If set, the server will not respond to the method. The client should
3304           not wait for a reply method.  If the server could not complete the
3305           method it will raise a channel or connection exception.
3306         </doc>
3307       </field>
3308     </method>
3309
3310     <method name="select-ok" synchronous="1" index="11">
3311       acknowledge confirm mode
3312       <doc>
3313         This method confirms to the client that the channel was successfully
3314         set to use publisher acknowledgements.
3315       </doc>
3316       <chassis name="client" implement="MUST"/>
3317     </method>
3318   </class>
3319
3320 </amqp>