2
2
// and the Mozilla Public License, version 2.0.
3
3
// Copyright (c) 2017-2024 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
4
4
5
- using System ;
6
5
using System . Collections . Generic ;
7
6
using System . Threading . Tasks ;
8
7
9
8
namespace RabbitMQ . AMQP . Client
10
9
{
11
- public class ConsumerException : Exception
12
- {
13
- public ConsumerException ( string message ) : base ( message )
14
- {
15
- }
16
- }
17
-
18
10
// 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>
19
17
public delegate Task MessageHandler ( IContext context , IMessage message ) ;
20
18
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>
21
24
public interface IConsumer : ILifeCycle
22
25
{
26
+ /// <summary>
27
+ /// Pause the consumer to stop receiving messages.
28
+ /// </summary>
23
29
void Pause ( ) ;
30
+
31
+ /// <summary>
32
+ /// Request to receive messages again.
33
+ /// </summary>
24
34
void Unpause ( ) ;
35
+
36
+ /// <summary>
37
+ /// Returns the number of unsettled messages.
38
+ /// </summary>
25
39
long UnsettledMessageCount { get ; }
26
40
}
27
41
28
42
public interface IContext
29
43
{
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>
35
47
/// </summary>
36
48
void Accept ( ) ;
37
49
38
50
///<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>
42
56
///</summary>
43
57
void Discard ( ) ;
44
58
45
59
///<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>
60
81
///</summary>
61
82
void Discard ( Dictionary < string , object > annotations ) ;
62
83
@@ -70,23 +91,27 @@ public interface IContext
70
91
void Requeue ( ) ;
71
92
72
93
///<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>
90
115
///</summary>
91
116
void Requeue ( Dictionary < string , object > annotations ) ;
92
117
}
0 commit comments