2009-08-31 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / RabbitMQ.Client / src / client / api / IModel.cs
1 // This source code is dual-licensed under the Apache License, version
2 // 2.0, and the Mozilla Public License, version 1.1.
3 //
4 // The APL v2.0:
5 //
6 //---------------------------------------------------------------------------
7 //   Copyright (C) 2007-2009 LShift Ltd., Cohesive Financial
8 //   Technologies LLC., and Rabbit Technologies Ltd.
9 //
10 //   Licensed under the Apache License, Version 2.0 (the "License");
11 //   you may not use this file except in compliance with the License.
12 //   You may obtain a copy of the License at
13 //
14 //       http://www.apache.org/licenses/LICENSE-2.0
15 //
16 //   Unless required by applicable law or agreed to in writing, software
17 //   distributed under the License is distributed on an "AS IS" BASIS,
18 //   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 //   See the License for the specific language governing permissions and
20 //   limitations under the License.
21 //---------------------------------------------------------------------------
22 //
23 // The MPL v1.1:
24 //
25 //---------------------------------------------------------------------------
26 //   The contents of this file are subject to the Mozilla Public License
27 //   Version 1.1 (the "License"); you may not use this file except in
28 //   compliance with the License. You may obtain a copy of the License at
29 //   http://www.rabbitmq.com/mpl.html
30 //
31 //   Software distributed under the License is distributed on an "AS IS"
32 //   basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
33 //   License for the specific language governing rights and limitations
34 //   under the License.
35 //
36 //   The Original Code is The RabbitMQ .NET Client.
37 //
38 //   The Initial Developers of the Original Code are LShift Ltd,
39 //   Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
40 //
41 //   Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
42 //   Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
43 //   are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
44 //   Technologies LLC, and Rabbit Technologies Ltd.
45 //
46 //   Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift
47 //   Ltd. Portions created by Cohesive Financial Technologies LLC are
48 //   Copyright (C) 2007-2009 Cohesive Financial Technologies
49 //   LLC. Portions created by Rabbit Technologies Ltd are Copyright
50 //   (C) 2007-2009 Rabbit Technologies Ltd.
51 //
52 //   All Rights Reserved.
53 //
54 //   Contributor(s): ______________________________________.
55 //
56 //---------------------------------------------------------------------------
57 using System;
58 using System.Collections;
59 using RabbitMQ.Client.Apigen.Attributes;
60 using RabbitMQ.Client.Events;
61
62 namespace RabbitMQ.Client
63 {
64     ///<summary>Common AMQP model, spanning the union of the
65     ///functionality offered by versions 0-8, 0-8qpid, and 0-9
66     ///(without WIP) of AMQP.</summary>
67     ///<remarks>
68     /// Extends the IDisposable interface, so that the "using"
69     /// statement can be used to scope the lifetime of a channel when
70     /// appropriate.
71     ///</remarks>
72     public interface IModel: IDisposable
73     {
74         ///<summary>Notifies the destruction of the model.</summary>
75         ///<remarks>
76         /// If the model is already destroyed at the time an event
77         /// handler is added to this event, the event handler will be
78         /// fired immediately.
79         ///</remarks>
80         event ModelShutdownEventHandler ModelShutdown;
81
82         ///<summary>Signalled when a Basic.Return command arrives from
83         ///the broker.</summary>
84         event BasicReturnEventHandler BasicReturn;
85
86         ///<summary>Signalled when an exception occurs in a callback
87         ///invoked by the model.</summary>
88         ///<remarks>
89         ///Examples of cases where this event will be signalled
90         ///include exceptions thrown in IBasicConsumer methods, or
91         ///exceptions thrown in ModelShutdownEventHandler delegates
92         ///etc.
93         ///</remarks>
94         event CallbackExceptionEventHandler CallbackException;
95
96         ///<summary>Returns null if the session is still in a state
97         ///where it can be used, or the cause of its closure
98         ///otherwise.</summary>
99         ShutdownEventArgs CloseReason { get; }
100
101         ///<summary>Returns true if the session is still in a state
102         ///where it can be used. Identical to checking if CloseReason
103         ///== null.</summary>
104         bool IsOpen { get; }
105
106         ///<summary>Construct a completely empty content header for
107         ///use with the Basic content class.</summary>
108         [AmqpContentHeaderFactory("basic")]
109         IBasicProperties CreateBasicProperties();
110
111         ///<summary>Construct a completely empty content header for
112         ///use with the File content class.</summary>
113         [AmqpContentHeaderFactory("file")]
114         IFileProperties CreateFileProperties();
115
116         ///<summary>Construct a completely empty content header for
117         ///use with the Stream content class.</summary>
118         [AmqpContentHeaderFactory("stream")]
119         IStreamProperties CreateStreamProperties();
120
121         ///<summary>(Spec method) Channel flow control functionality.</summary>
122         ///<remarks>
123         ///</remarks>
124         [return: AmqpFieldMapping(null, "active")]
125         void ChannelFlow(bool active);
126
127         ///<summary>(Spec method) Declare an exchange.</summary>
128         ///<remarks>
129         ///The exchange is declared non-passive, non-autodelete, and
130         ///non-internal, with no arguments. The "nowait" option is not
131         ///exercised.
132         ///</remarks>
133         [AmqpMethodDoNotImplement(null)]
134         void ExchangeDeclare(string exchange, string type, bool durable);
135
136         ///<summary>(Spec method) Declare an exchange.</summary>
137         ///<remarks>
138         ///The exchange is declared non-passive, non-durable, non-autodelete, and
139         ///non-internal, with no arguments. The "nowait" option is not
140         ///exercised.
141         ///</remarks>
142         [AmqpMethodDoNotImplement(null)]
143         void ExchangeDeclare(string exchange, string type);
144
145         ///<summary>(Spec method) Declare an exchange.</summary>
146         void ExchangeDeclare(string exchange,
147                              string type,
148                              bool passive,
149                              bool durable,
150                              bool autoDelete,
151                              bool @internal,
152                              [AmqpNowaitArgument(null)]
153                              bool nowait,
154                              IDictionary arguments);
155
156         ///<summary>(Spec method) Delete an exchange.</summary>
157         void ExchangeDelete(string exchange,
158                             bool ifUnused,
159                             [AmqpNowaitArgument(null)]
160                             bool nowait);
161
162         ///<summary>(Spec method) Declare a queue.</summary>
163         ///<remarks>
164         ///The queue is declared non-passive, non-durable,
165         ///but exclusive and autodelete, with no arguments. The
166         ///server autogenerates a name for the queue - the generated
167         ///name is the return value of this method.
168         ///</remarks>
169         [AmqpMethodDoNotImplement(null)]
170         string QueueDeclare();
171
172         ///<summary>(Spec method) Declare a queue.</summary>
173         ///<remarks>
174         ///The queue is declared non-passive, non-durable,
175         ///non-exclusive, and non-autodelete, with no arguments.
176         ///</remarks>
177         [AmqpMethodDoNotImplement(null)]
178         string QueueDeclare(string queue);
179
180         ///<summary>(Spec method) Declare a queue.</summary>
181         ///<remarks>
182         ///The queue is declared non-passive, non-exclusive, and
183         ///non-autodelete, with no arguments.
184         ///</remarks>
185         [AmqpMethodDoNotImplement(null)]
186         string QueueDeclare(string queue,
187                             bool durable);
188
189         ///<summary>(Spec method) Declare a queue.</summary>
190         ///<remarks>
191         ///Returns the name of the queue that was declared.
192         ///</remarks>
193         [return: AmqpFieldMapping(null, "queue")]
194         string QueueDeclare(string queue,
195                             bool passive,
196                             bool durable,
197                             bool exclusive,
198                             bool autoDelete,
199                             [AmqpNowaitArgument(null)]
200                             bool nowait,
201                             IDictionary arguments);
202
203         ///<summary>(Spec method) Bind a queue to an exchange.</summary>
204         void QueueBind(string queue,
205                        string exchange,
206                        string routingKey,
207                        [AmqpNowaitArgument(null)]
208                        bool nowait,
209                        IDictionary arguments);
210
211         ///<summary>(Spec method) Unbind a queue from an exchange.</summary>
212         ///<remarks>
213         ///Note: This operation is only supported when communicating
214         ///using AMQP protocol version 0-9, or when communicating with
215         ///a 0-8 broker that has been enhanced with the unofficial
216         ///addition of a queue.unbind method.
217         ///</remarks>
218         [AmqpUnsupported("RabbitMQ.Client.Framing.v0_8qpid")]
219         void QueueUnbind(string queue,
220                          string exchange,
221                          string routingKey,
222                          IDictionary arguments);
223
224         ///<summary>(Spec method) Purge a queue of messages.</summary>
225         ///<remarks>
226         ///Returns the number of messages purged. If nowait is
227         ///specified, returns <code>uint.MaxValue</code>.
228         ///</remarks>
229         [return: AmqpFieldMapping(null, "messageCount")]
230         uint QueuePurge(string queue,
231                         [AmqpNowaitArgument(null, "0xFFFFFFFF")]
232                         bool nowait);
233
234         ///<summary>(Spec method) Delete a queue.</summary>
235         ///<remarks>
236         ///Returns the number of messages purged during queue
237         ///deletion. If nowait is specified, returns
238         ///<code>uint.MaxValue</code>.
239         ///</remarks>
240         [return: AmqpFieldMapping(null, "messageCount")]
241         uint QueueDelete(string queue,
242                          bool ifUnused,
243                          bool ifEmpty,
244                          [AmqpNowaitArgument(null, "0xFFFFFFFF")]
245                          bool nowait);
246
247         ///<summary>Start a Basic content-class consumer.</summary>
248         ///<remarks>
249         ///The consumer is started with noAck=false (i.e. BasicAck is required),
250         ///an empty consumer tag (i.e. the server creates and returns a fresh consumer tag),
251         ///noLocal=false and exclusive=false.
252         ///</remarks>
253         [AmqpMethodDoNotImplement(null)]
254         string BasicConsume(string queue,
255                             IDictionary filter,
256                             IBasicConsumer consumer);
257
258         ///<summary>Start a Basic content-class consumer.</summary>
259         ///<remarks>
260         ///The consumer is started with
261         ///an empty consumer tag (i.e. the server creates and returns a fresh consumer tag),
262         ///noLocal=false and exclusive=false.
263         ///</remarks>
264         [AmqpMethodDoNotImplement(null)]
265         string BasicConsume(string queue,
266                             bool noAck,
267                             IDictionary filter,
268                             IBasicConsumer consumer);
269
270         ///<summary>Start a Basic content-class consumer.</summary>
271         ///<remarks>
272         ///The consumer is started with
273         ///noLocal=false and exclusive=false.
274         ///</remarks>
275         [AmqpMethodDoNotImplement(null)]
276         string BasicConsume(string queue,
277                             bool noAck,
278                             string consumerTag,
279                             IDictionary filter,
280                             IBasicConsumer consumer);
281
282         ///<summary>Start a Basic content-class consumer.</summary>
283         [AmqpMethodDoNotImplement(null)]
284         string BasicConsume(string queue,
285                             bool noAck,
286                             string consumerTag,
287                             bool noLocal,
288                             bool exclusive,
289                             IDictionary filter,
290                             IBasicConsumer consumer);
291
292         ///<summary>Delete a Basic content-class consumer.</summary>
293         [AmqpMethodDoNotImplement(null)]
294         void BasicCancel(string consumerTag);
295
296         ///<summary>(Spec method) Configures QoS parameters of the Basic content-class.</summary>
297         void BasicQos(uint prefetchSize,
298                       ushort prefetchCount,
299                       bool global);
300
301         ///<summary>(Spec method) Convenience overload of BasicPublish.</summary>
302         ///<remarks>
303         ///The publication occurs with mandatory=false and immediate=false.
304         ///</remarks>
305         [AmqpMethodDoNotImplement(null)]
306         void BasicPublish(PublicationAddress addr,
307                           IBasicProperties basicProperties,
308                           byte[] body);
309
310         ///<summary>(Spec method) Convenience overload of BasicPublish.</summary>
311         ///<remarks>
312         ///The publication occurs with mandatory=false and immediate=false.
313         ///</remarks>
314         [AmqpMethodDoNotImplement(null)]
315         void BasicPublish(string exchange,
316                           string routingKey,
317                           IBasicProperties basicProperties,
318                           byte[] body);
319
320         ///<summary>(Spec method) Publish a message using the Basic
321         ///content-class.</summary>
322         [AmqpMethodDoNotImplement(null)]
323         void BasicPublish(string exchange,
324                           string routingKey,
325                           bool mandatory,
326                           bool immediate,
327                           IBasicProperties basicProperties,
328                           byte[] body);
329
330         ///<summary>(Spec method) Acknowledge one or more delivered message(s).</summary>
331         void BasicAck(ulong deliveryTag,
332                       bool multiple);
333
334         ///<summary>(Spec method) Reject a delivered message.</summary>
335         void BasicReject(ulong deliveryTag,
336                          bool requeue);
337
338         ///<summary>(Spec method)</summary>
339         void BasicRecover(bool requeue);
340
341         ///<summary>(Spec method) Retrieve an individual message, if
342         ///one is available; returns null if the server answers that
343         ///no messages are currently available. See also
344         ///IModel.BasicAck.</summary>
345         [AmqpMethodDoNotImplement(null)]
346         BasicGetResult BasicGet(string queue,
347                                 bool noAck);
348
349         ///<summary>(Spec method) Enable TX mode for this session.</summary>
350         void TxSelect();
351
352         ///<summary>(Spec method) Commit this session's active TX
353         ///transaction.</summary>
354         void TxCommit();
355
356         ///<summary>(Spec method) Roll back this session's active TX
357         ///transaction.</summary>
358         void TxRollback();
359
360         ///<summary>(Spec method) Enable DTX mode for this session.</summary>
361         void DtxSelect();
362
363         ///<summary>(Spec method)</summary>
364         void DtxStart(string dtxIdentifier);
365
366         ///<summary>Close this session.</summary>
367         ///<remarks>
368         ///If the session is already closed (or closing), then this
369         ///method does nothing but wait for the in-progress close
370         ///operation to complete. This method will not return to the
371         ///caller until the shutdown is complete.
372         ///</remarks>
373         [AmqpMethodDoNotImplement(null)]
374         void Close();
375         
376         ///<summary>Close this session.</summary>
377         ///<remarks>
378         ///The method behaves in the same way as Close(), with the only
379         ///difference that the model is closed with the given model
380         ///close code and message.
381         ///<para>
382         ///The close code (See under "Reply Codes" in the AMQP specification)
383         ///</para>
384         ///<para>
385         ///A message indicating the reason for closing the model
386         ///</para>
387         ///</remarks>
388         [AmqpMethodDoNotImplement(null)]
389         void Close(ushort replyCode, string replyText);
390         
391         ///<summary>Abort this session.</summary>
392         ///<remarks>
393         ///If the session is already closed (or closing), then this
394         ///method does nothing but wait for the in-progress close
395         ///operation to complete. This method will not return to the
396         ///caller until the shutdown is complete.
397         ///In comparison to normal Close() method, Abort() will not throw
398         ///AlreadyClosedException or IOException during closing model.
399         ///</remarks>
400         [AmqpMethodDoNotImplement(null)]
401         void Abort();
402         
403         ///<summary>Abort this session.</summary>
404         ///<remarks>
405         ///The method behaves in the same way as Abort(), with the only
406         ///difference that the model is closed with the given model
407         ///close code and message.
408         ///<para>
409         ///The close code (See under "Reply Codes" in the AMQP specification)
410         ///</para>
411         ///<para>
412         ///A message indicating the reason for closing the model
413         ///</para>
414         ///</remarks>
415         [AmqpMethodDoNotImplement(null)]
416         void Abort(ushort replyCode, string replyText);
417     }
418
419     ///<summary>Represents Basic.GetOk responses from the server.</summary>
420     ///<remarks>
421     /// Basic.Get either returns an instance of this class, or null if
422     /// a Basic.GetEmpty was received.
423     ///</remarks>
424     public class BasicGetResult
425     {
426         private ulong m_deliveryTag;
427         private bool m_redelivered;
428         private string m_exchange;
429         private string m_routingKey;
430         private uint m_messageCount;
431         private IBasicProperties m_basicProperties;
432         private byte[] m_body;
433
434         ///<summary>Sets the new instance's properties from the
435         ///arguments passed in.</summary>
436         public BasicGetResult(ulong deliveryTag,
437                               bool redelivered,
438                               string exchange,
439                               string routingKey,
440                               uint messageCount,
441                               IBasicProperties basicProperties,
442                               byte[] body)
443         {
444             m_deliveryTag = deliveryTag;
445             m_redelivered = redelivered;
446             m_exchange = exchange;
447             m_routingKey = routingKey;
448             m_messageCount = messageCount;
449             m_basicProperties = basicProperties;
450             m_body = body;
451         }
452
453         ///<summary>Retrieve the delivery tag for this message. See also IModel.BasicAck.</summary>
454         public ulong DeliveryTag { get { return m_deliveryTag; } }
455         ///<summary>Retrieve the redelivered flag for this message.</summary>
456         public bool Redelivered { get { return m_redelivered; } }
457         ///<summary>Retrieve the exchange this message was published to.</summary>
458         public string Exchange { get { return m_exchange; } }
459         ///<summary>Retrieve the routing key with which this message was published.</summary>
460         public string RoutingKey { get { return m_routingKey; } }
461
462         ///<summary>Retrieve the number of messages pending on the
463         ///queue, excluding the message being delivered.</summary>
464         ///<remarks>
465         /// Note that this figure is indicative, not reliable, and can
466         /// change arbitrarily as messages are added to the queue and
467         /// removed by other clients.
468         ///</remarks>
469         public uint MessageCount { get { return m_messageCount; } }
470
471         ///<summary>Retrieves the Basic-class content header properties for this message.</summary>
472         public IBasicProperties BasicProperties { get { return m_basicProperties; } }
473         ///<summary>Retrieves the body of this message.</summary>
474         public byte[] Body { get { return m_body; } }
475     }
476 }
477
478 namespace RabbitMQ.Client.Impl
479 {
480     ///<summary>Not part of the public API. Extension of IModel to
481     ///include utilities and connection-setup routines needed by the
482     ///implementation side.</summary>
483     ///
484     ///<remarks>This interface is used by the API autogeneration
485     ///process. The AMQP XML specifications are read by the spec
486     ///compilation tool, and after the basic method interface and
487     ///implementation classes are generated, this interface is
488     ///scanned, and a spec-version-specific implementation is
489     ///autogenerated. Annotations are used on certain methods, return
490     ///types, and parameters, to customise the details of the
491     ///autogeneration process.</remarks>
492     ///
493     ///<see cref="RabbitMQ.Client.Impl.ModelBase"/>
494     ///<see cref="RabbitMQ.Client.Framing.Impl.v0_9.Model"/>
495     public interface IFullModel : RabbitMQ.Client.IModel
496     {
497         ///<summary>Used to send a Basic.Publish method. Called by the
498         ///public publish method after potential null-reference issues
499         ///have been rectified.</summary>
500         [AmqpMethodMapping(null, "basic", "publish")]
501         void _Private_BasicPublish(string exchange,
502                                    string routingKey,
503                                    bool mandatory,
504                                    bool immediate,
505                                    [AmqpContentHeaderMapping]
506                                    IBasicProperties basicProperties,
507                                    [AmqpContentBodyMapping]
508                                    byte[] body);
509
510         ///<summary>Used to send a Basic.Consume method. The public
511         ///consume API calls this while also managing internal
512         ///datastructures.</summary>
513         [AmqpForceOneWay]
514         [AmqpMethodMapping(null, "basic", "consume")]
515         void _Private_BasicConsume(string queue,
516                                    string consumerTag,
517                                    bool noLocal,
518                                    bool noAck,
519                                    bool exclusive,
520                                    bool nowait,
521                                    [AmqpUnsupported("RabbitMQ.Client.Framing.v0_8")]
522                                    [AmqpFieldMapping("RabbitMQ.Client.Framing.v0_8qpid",
523                                                      "arguments")]
524                                    IDictionary filter);
525
526         ///<summary>Handle incoming Basic.ConsumeOk methods.</summary>
527         void HandleBasicConsumeOk(string consumerTag);
528
529         ///<summary>Used to send a Basic.Cancel method. The public
530         ///consume API calls this while also managing internal
531         ///datastructures.</summary>
532         [AmqpForceOneWay]
533         [AmqpMethodMapping(null, "basic", "cancel")]
534         void _Private_BasicCancel(string consumerTag,
535                                   bool nowait);
536
537         ///<summary>Handle incoming Basic.CancelOk methods.</summary>
538         void HandleBasicCancelOk(string consumerTag);
539
540         ///<summary>Used to send a Channel.Open. Called during session
541         ///initialisation.</summary>
542         [AmqpMethodMapping(null, "channel", "open")]
543         void _Private_ChannelOpen(string outOfBand);
544
545         ///<summary>Used to send a Channel.CloseOk. Called during
546         ///session shutdown.</summary>
547         [AmqpMethodMapping(null, "channel", "close-ok")]
548         void _Private_ChannelCloseOk();
549
550         ///<summary>Used to send a Channel.Close. Called during
551         ///session shutdown.</summary>
552         [AmqpForceOneWay]
553         [AmqpMethodMapping(null, "channel", "close")]
554         void _Private_ChannelClose(ushort replyCode,
555                                    string replyText,
556                                    ushort classId,
557                                    ushort methodId);
558
559         ///<summary>Used to send a Basic.Get. Basic.Get is a special
560         ///case, since it can result in a Basic.GetOk or a
561         ///Basic.GetEmpty, so this level of manual control is
562         ///required.</summary>
563         [AmqpForceOneWay]
564         [AmqpMethodMapping(null, "basic", "get")]
565         void _Private_BasicGet(string queue,
566                                bool noAck);
567
568         ///<summary>Handle incoming Basic.GetOk methods. Routes the
569         ///information to a waiting Basic.Get continuation.</summary>
570         void HandleBasicGetOk(ulong deliveryTag,
571                               bool redelivered,
572                               string exchange,
573                               string routingKey,
574                               uint messageCount,
575                               [AmqpContentHeaderMapping]
576                               IBasicProperties basicProperties,
577                               [AmqpContentBodyMapping]
578                               byte[] body);
579
580         ///<summary>Handle incoming Basic.GetEmpty methods. Routes the
581         ///information to a waiting Basic.Get continuation.</summary>
582         ///<remarks>
583         /// Note that the clusterId field is ignored, as in the
584         /// specification it notes that it is "deprecated pending
585         /// review".
586         ///</remarks>
587         void HandleBasicGetEmpty();
588
589         ///<summary>Handle incoming Basic.Deliver methods. Dispatches
590         ///to waiting consumers.</summary>
591         void HandleBasicDeliver(string consumerTag,
592                                 ulong deliveryTag,
593                                 bool redelivered,
594                                 string exchange,
595                                 string routingKey,
596                                 [AmqpContentHeaderMapping]
597                                 IBasicProperties basicProperties,
598                                 [AmqpContentBodyMapping]
599                                 byte[] body);
600
601         ///<summary>Handle incoming Basic.Return methods. Signals a
602         ///BasicReturnEvent.</summary>
603         void HandleBasicReturn(ushort replyCode,
604                                string replyText,
605                                string exchange,
606                                string routingKey,
607                                [AmqpContentHeaderMapping]
608                                IBasicProperties basicProperties,
609                                [AmqpContentBodyMapping]
610                                byte[] body);
611                                
612         ///<summary>Used to send a Channel.FlowOk. Confirms that
613         ///Channel.Flow from the broker was processed.</summary>
614         [AmqpMethodMapping(null, "channel", "flow-ok")]
615         void _Private_ChannelFlowOk();
616         
617         ///<summary>Handle incoming Channel.Flow methods. Either
618         ///stops or resumes sending the methods that have content.</summary>
619         void HandleChannelFlow(bool active);
620
621         ///<summary>Handle an incoming Channel.Close. Shuts down the
622         ///session and model.</summary>
623         void HandleChannelClose(ushort replyCode,
624                                 string replyText,
625                                 ushort classId,
626                                 ushort methodId);
627
628         ///<summary>Handle an incoming Channel.CloseOk.</summary>
629         void HandleChannelCloseOk();
630
631         ///////////////////////////////////////////////////////////////////////////
632         // Connection-related methods, for use in channel 0 during
633         // connection startup/shutdown.
634
635         ///<summary>Handle an incoming Connection.Start. Used during
636         ///connection initialisation.</summary>
637         void HandleConnectionStart(byte versionMajor,
638                                    byte versionMinor,
639                                    IDictionary serverProperties,
640                                    byte[] mechanisms,
641                                    byte[] locales);
642
643         ///<summary>Sends a Connection.StartOk, and waits for a
644         ///Connection.Tune. Used during connection
645         ///initialisation.</summary>
646         [return: AmqpMethodMapping(null, "connection", "tune")]
647         ConnectionTuneDetails ConnectionStartOk(IDictionary clientProperties,
648                                                 string mechanism,
649                                                 byte[] response,
650                                                 string locale);
651
652         ///<summary>Sends a Connection.TuneOk. Used during connection
653         ///initialisation.</summary>
654         void ConnectionTuneOk(ushort channelMax,
655                               uint frameMax,
656                               ushort heartbeat);
657
658
659         ///<summary>Used to send a Connection.Open. Called during
660         ///connection startup.</summary>
661         [AmqpForceOneWay]
662         [AmqpMethodMapping(null, "connection", "open")]
663         void _Private_ConnectionOpen(string virtualHost,
664                                      string capabilities,
665                                      bool insist);
666
667         ///<summary>Handle an incoming Connection.OpenOk.</summary>
668         void HandleConnectionOpenOk(string knownHosts);
669
670         ///<summary>Handle an incoming Connection.Redirect.</summary>
671         void HandleConnectionRedirect(string host,
672                                       string knownHosts);
673
674         ///<summary>Used to send a Connection.Close. Called during
675         ///connection shutdown.</summary>
676         [AmqpMethodMapping(null, "connection", "close")]
677         void _Private_ConnectionClose(ushort replyCode,
678                                       string replyText,
679                                       ushort classId,
680                                       ushort methodId);
681
682         ///<summary>Used to send a Connection.CloseOk. Called during
683         ///connection shutdown.</summary>
684         [AmqpMethodMapping(null, "connection", "close-ok")]
685         void _Private_ConnectionCloseOk();
686
687         ///<summary>Handle an incoming Connection.Close. Shuts down the
688         ///connection and all sessions and models.</summary>
689         void HandleConnectionClose(ushort replyCode,
690                                    string replyText,
691                                    ushort classId,
692                                    ushort methodId);
693     }
694
695     ///<summary>Essential information from an incoming Connection.Tune
696     ///method.</summary>
697     public struct ConnectionTuneDetails
698     {
699         ///<summary>The peer's suggested channel-max parameter.</summary>
700         public ushort m_channelMax;
701         ///<summary>The peer's suggested frame-max parameter.</summary>
702         public uint m_frameMax;
703         ///<summary>The peer's suggested heartbeat parameter.</summary>
704         public ushort m_heartbeat;
705     }
706 }
707
708 namespace RabbitMQ.Client.Apigen.Attributes
709 {
710     ///<summary>Base class for attributes for controlling the API
711     ///autogeneration process.</summary>
712     public abstract class AmqpApigenAttribute : Attribute
713     {
714         ///<summary>The specification namespace (i.e. version) that
715         ///this attribute applies to, or null for all specification
716         ///versions.</summary>
717         public string m_namespaceName;
718
719         public AmqpApigenAttribute(string namespaceName)
720         {
721             m_namespaceName = namespaceName;
722         }
723     }
724
725     ///<summary>Causes the API generator to ignore the attributed method.</summary>
726     ///
727     ///<remarks>Mostly used to declare convenience overloads of
728     ///various AMQP methods in the IModel interface. The API
729     ///autogeneration process should of course not attempt to produce
730     ///an implementation of the convenience methods, as they will be
731     ///implemented by hand with sensible defaults, delegating to the
732     ///autogenerated variant of the method concerned.</remarks>
733     [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
734     public class AmqpMethodDoNotImplementAttribute : AmqpApigenAttribute
735     {
736         public AmqpMethodDoNotImplementAttribute(string namespaceName)
737             : base(namespaceName) { }
738     }
739
740     ///<summary>Causes the API generator to generate asynchronous
741     ///receive code for the attributed method.</summary>
742     [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
743     public class AmqpAsynchronousHandlerAttribute : AmqpApigenAttribute
744     {
745         public AmqpAsynchronousHandlerAttribute(string namespaceName)
746             : base(namespaceName) { }
747     }
748
749     ///<summary>Causes the API generator to generate
750     ///exception-throwing code for, instead of simply ignoring, the
751     ///attributed method.</summary>
752     ///
753     ///<see cref="AmqpMethodDoNotImplementAttribute"/>
754     [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
755     public class AmqpUnsupportedAttribute : AmqpApigenAttribute
756     {
757         public AmqpUnsupportedAttribute(string namespaceName)
758             : base(namespaceName) { }
759     }
760
761     ///<summary>Informs the API generator which AMQP method field to
762     ///use for either a parameter in a request, or for a simple result
763     ///in a reply.</summary>
764     [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
765     public class AmqpFieldMappingAttribute : AmqpApigenAttribute
766     {
767         public string m_fieldName;
768
769         public AmqpFieldMappingAttribute(string namespaceName,
770                                 string fieldName)
771             : base(namespaceName)
772         {
773             m_fieldName = fieldName;
774         }
775     }
776
777     ///<summary>Informs the API generator which AMQP method to use for
778     ///either a request (if applied to an IModel method) or a reply
779     ///(if applied to an IModel method result).</summary>
780     [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
781     public class AmqpMethodMappingAttribute : AmqpApigenAttribute
782     {
783         public string m_className;
784         public string m_methodName;
785
786         public AmqpMethodMappingAttribute(string namespaceName,
787                                  string className,
788                                  string methodName)
789             : base(namespaceName)
790         {
791             m_className = className;
792             m_methodName = methodName;
793         }
794     }
795
796     ///<summary>This attribute, if placed on a parameter in an IModel
797     ///method, causes it to be interpreted as a "nowait" parameter for
798     ///the purposes of autogenerated RPC reply continuation management
799     ///and control.</summary>
800     [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
801     public class AmqpNowaitArgumentAttribute : AmqpApigenAttribute
802     {
803         public string m_replacementExpression;
804
805         public AmqpNowaitArgumentAttribute(string namespaceName)
806             : this(namespaceName, null) { }
807
808         public AmqpNowaitArgumentAttribute(string namespaceName,
809                                   string replacementExpression)
810             : base(namespaceName)
811         {
812             m_replacementExpression = replacementExpression;
813         }
814     }
815
816     ///<summary>This attribute, if placed on a method in IModel,
817     ///causes the method to be interpreted as a factory method
818     ///producing a protocol-specific implementation of a common
819     ///content header interface.</summary>
820     public class AmqpContentHeaderFactoryAttribute : Attribute
821     {
822         public string m_contentClass;
823
824         public AmqpContentHeaderFactoryAttribute(string contentClass)
825         {
826             m_contentClass = contentClass;
827         }
828     }
829
830     ///<summary>This attribute, if placed on a parameter in a
831     ///content-carrying IModel method, causes it to be sent as part of
832     ///the content header frame.</summary>
833     public class AmqpContentHeaderMappingAttribute : Attribute
834     {
835         public AmqpContentHeaderMappingAttribute() { }
836     }
837
838     ///<summary>This attribute, if placed on a parameter in a
839     ///content-carrying IModel method, causes it to be sent as part of
840     ///the content body frame.</summary>
841     public class AmqpContentBodyMappingAttribute : Attribute
842     {
843         public AmqpContentBodyMappingAttribute() { }
844     }
845
846     ///<summary>This attribute, placed on an IModel method, causes
847     ///what would normally be an RPC, sent with ModelRpc, to be sent
848     ///as if it were oneway, with ModelSend. The assumption that this
849     ///is for a custom continuation (e.g. for BasicConsume/BasicCancel
850     ///etc.)</summary>
851     public class AmqpForceOneWayAttribute : Attribute
852     {
853         public AmqpForceOneWayAttribute() { }
854     }
855 }