22// and the Mozilla Public License, version 2.0.
33// Copyright (c) 2017-2024 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
44
5- using System ;
65using System . Collections . Generic ;
76using System . Threading . Tasks ;
87
98namespace RabbitMQ . AMQP . Client
109{
11- public class ConsumerException : Exception
12- {
13- public ConsumerException ( string message ) : base ( message )
14- {
15- }
16- }
17-
1810 // TODO cancellation token
11+ /// <summary>
12+ /// Delegate to process an incoming message.
13+ /// </summary>
14+ /// <param name="context">The message context.</param>
15+ /// <param name="message">The message itself.</param>
16+ /// <returns><see cref="Task"/> that represents the async operation.</returns>
1917 public delegate Task MessageHandler ( IContext context , IMessage message ) ;
2018
19+ /// <summary>
20+ /// <para>API to consume messages from a RabbitMQ queue.</para>
21+ /// <para>Instances are configured and created with a <see cref="IConsumerBuilder"/>.</para>
22+ /// <para>See <see cref="IConnection.ConsumerBuilder()"/> and <see cref="IConsumerBuilder"/>.</para>
23+ /// </summary>
2124 public interface IConsumer : ILifeCycle
2225 {
26+ /// <summary>
27+ /// Pause the consumer to stop receiving messages.
28+ /// </summary>
2329 void Pause ( ) ;
30+
31+ /// <summary>
32+ /// Request to receive messages again.
33+ /// </summary>
2434 void Unpause ( ) ;
35+
36+ /// <summary>
37+ /// Returns the number of unsettled messages.
38+ /// </summary>
2539 long UnsettledMessageCount { get ; }
2640 }
2741
2842 public interface IContext
2943 {
30- ///<summary>
31- /// Accept the message (AMQP 1.0 <code>accepted</code> outcome).
32- ///
33- /// This means the message has been processed and the broker can delete it.
34- ///
44+ /// <summary>
45+ /// <para>Accept the message (AMQP 1.0 <c>accepted</c> outcome).</para>
46+ /// <para>This means the message has been processed and the broker can delete it.</para>
3547 /// </summary>
3648 void Accept ( ) ;
3749
3850 ///<summary>
39- /// Discard the message (AMQP 1.0 <code>rejected</code> outcome).
40- ///This means the message cannot be processed because it is invalid, the broker can drop it
41- /// or dead-letter it if it is configured.
51+ /// <para>Discard the message (AMQP 1.0 <c>rejected</c> outcome).</para>
52+ /// <para>
53+ /// This means the message cannot be processed because it is invalid, the broker can
54+ /// drop it or dead-letter it if it is configured.
55+ /// </para>
4256 ///</summary>
4357 void Discard ( ) ;
4458
4559 ///<summary>
46- ///Discard the message with annotations to combine with the existing message annotations.
47- ///This means the message cannot be processed because it is invalid, the broker can drop it
48- ///or dead-letter it if it is configured.
49- ///Application-specific annotation keys must start with the <code>x-opt-</code> prefix.
50- ///Annotation keys the broker understands starts with <code>x-</code>, but not with <code>x-opt-
51- ///</code>.
52- ///This maps to the AMQP 1.0 <code>
53- ///modified{delivery-failed = true, undeliverable-here = true}</code> outcome.
54- /// <param name="annotations"> annotations message annotations to combine with existing ones </param>
55- ///<a
56- /// href="https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-modified">AMQP
57- /// 1.0 <code>modified</code> outcome</a>
58- ///
59- /// The annotations can be used only with Quorum queues, see https://www.rabbitmq.com/docs/amqp#modified-outcome
60+ /// <para>
61+ /// Discard the message with annotations to combine with the existing message annotations.
62+ /// </para>
63+ /// <para>
64+ /// This means the message cannot be processed because it is invalid, the broker can drop
65+ /// it or dead-letter it if it is configured.
66+ /// </para>
67+ /// <para>
68+ /// Application-specific annotation keys must start with the <c>x-opt-</c> prefix.
69+ /// </para>
70+ /// <para>
71+ /// Annotation keys that the broker understands start with <c>x-</c>, but not with
72+ /// <c>x-opt-</c>. This maps to the AMQP 1.0 <c>modified{delivery-failed = false,
73+ /// undeliverable-here = false}</c> outcome.
74+ /// </para>
75+ /// <para>
76+ /// The annotations can be used only with Quorum queues, see
77+ /// <a href="https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-modified">
78+ /// AMQP 1.0 <c>modified</c> outcome.</a>
79+ /// </para>
80+ /// <param name="annotations">Message annotations to combine with existing ones.</param>
6081 ///</summary>
6182 void Discard ( Dictionary < string , object > annotations ) ;
6283
@@ -70,23 +91,27 @@ public interface IContext
7091 void Requeue ( ) ;
7192
7293 ///<summary>
73- ///Requeue the message with annotations to combine with the existing message annotations.
74- ///
75- ///This means the message has not been processed and the broker can requeue it and deliver it
76- /// to the same or a different consumer.
77- /// Application-specific annotation keys must start with the <code>x-opt-</code> prefix.
78- /// Annotation keys the broker understands starts with <code>x-</code>, but not with <code>x-opt-
79- /// </code>.
80- ///
81- /// This maps to the AMQP 1.0 <code>
82- /// modified{delivery-failed = false, undeliverable-here = false}</code> outcome.
83- ///
84- /// <param name="annotations"> annotations message annotations to combine with existing ones </param>
85- ///<a
86- /// href="https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-modified">AMQP
87- /// 1.0 <code>modified</code> outcome</a>
88- ///
89- ///The annotations can be used only with Quorum queues, see https://www.rabbitmq.com/docs/amqp#modified-outcome
94+ /// <para>
95+ /// Requeue the message with annotations to combine with the existing message annotations.
96+ /// </para>
97+ /// <para>
98+ /// This means the message has not been processed and the broker can requeue it and
99+ /// deliver it to the same or a different consumer.
100+ /// </para>
101+ /// <para>
102+ /// Application-specific annotation keys must start with the <c>x-opt-</c> prefix.
103+ /// </para>
104+ /// <para>
105+ /// Annotation keys that the broker understands start with <c>x-</c>, but not with
106+ /// <c>x-opt-</c>. This maps to the AMQP 1.0 <c>modified{delivery-failed = false,
107+ /// undeliverable-here = false}</c> outcome.
108+ /// </para>
109+ /// <para>
110+ /// The annotations can be used only with Quorum queues, see
111+ /// <a href="https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-modified">
112+ /// AMQP 1.0 <c>modified</c> outcome.</a>
113+ /// </para>
114+ /// <param name="annotations">Message annotations to combine with existing ones.</param>
90115 ///</summary>
91116 void Requeue ( Dictionary < string , object > annotations ) ;
92117 }
0 commit comments