@@ -36,6 +36,8 @@ namespace RabbitMQ.Client.Impl
36
36
{
37
37
internal class RecordedConsumer : IRecordedConsumer
38
38
{
39
+ private readonly AutorecoveringModel _model ;
40
+
39
41
public RecordedConsumer ( AutorecoveringModel model , string queue , string consumerTag )
40
42
{
41
43
if ( model is null )
@@ -44,7 +46,7 @@ public RecordedConsumer(AutorecoveringModel model, string queue, string consumer
44
46
}
45
47
else
46
48
{
47
- Model = model ;
49
+ _model = model ;
48
50
}
49
51
50
52
if ( queue is null )
@@ -55,7 +57,7 @@ public RecordedConsumer(AutorecoveringModel model, string queue, string consumer
55
57
{
56
58
if ( queue == string . Empty )
57
59
{
58
- Queue = model . CurrentQueue ;
60
+ Queue = _model . CurrentQueue ;
59
61
}
60
62
else
61
63
{
@@ -73,27 +75,23 @@ public RecordedConsumer(AutorecoveringModel model, string queue, string consumer
73
75
}
74
76
}
75
77
76
- public AutorecoveringModel Model { get ; }
78
+ public AutorecoveringModel Model
79
+ {
80
+ get { return _model ; }
81
+ }
82
+
83
+ public string Queue { get ; set ; }
84
+ public string ConsumerTag { get ; set ; }
77
85
public IDictionary < string , object > Arguments { get ; set ; }
78
86
public bool AutoAck { get ; set ; }
79
- public IBasicConsumer Consumer { get ; set ; }
80
- public string ConsumerTag { get ; set ; }
81
87
public bool Exclusive { get ; set ; }
82
- public string Queue { get ; set ; }
88
+ public IBasicConsumer Consumer { get ; set ; }
83
89
84
90
public string Recover ( IModel channelToUse )
85
91
{
86
- string queueName = Queue ;
87
- if ( string . IsNullOrEmpty ( queueName ) )
88
- {
89
- // https://www.rabbitmq.com/amqp-0-9-1-reference.html#domain.queue-name
90
- queueName = channelToUse . CurrentQueue ;
91
- }
92
-
93
- ConsumerTag = channelToUse . BasicConsume ( queueName , AutoAck ,
92
+ ConsumerTag = channelToUse . BasicConsume ( Queue , AutoAck ,
94
93
ConsumerTag , false , Exclusive ,
95
94
Arguments , Consumer ) ;
96
-
97
95
return ConsumerTag ;
98
96
}
99
97
@@ -115,29 +113,10 @@ public RecordedConsumer WithConsumer(IBasicConsumer value)
115
113
return this ;
116
114
}
117
115
118
- public RecordedConsumer WithConsumerTag ( string value )
119
- {
120
- if ( string . IsNullOrEmpty ( value ) )
121
- {
122
- throw new System . ArgumentNullException ( nameof ( value ) ) ;
123
- }
124
- else
125
- {
126
- ConsumerTag = value ;
127
- }
128
- return this ;
129
- }
130
-
131
116
public RecordedConsumer WithExclusive ( bool value )
132
117
{
133
118
Exclusive = value ;
134
119
return this ;
135
120
}
136
-
137
- public RecordedConsumer WithQueue ( string value )
138
- {
139
- Queue = value ?? throw new System . ArgumentNullException ( nameof ( value ) ) ;
140
- return this ;
141
- }
142
121
}
143
122
}
0 commit comments