@@ -36,24 +36,33 @@ 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
- if ( model == null )
43
+ if ( model is null )
42
44
{
43
45
throw new ArgumentNullException ( nameof ( model ) ) ;
44
46
}
45
47
else
46
48
{
47
- Model = model ;
49
+ _model = model ;
48
50
}
49
51
50
- if ( string . IsNullOrEmpty ( queue ) )
52
+ if ( queue is null )
51
53
{
52
- throw new ArgumentNullException ( nameof ( consumerTag ) ) ;
54
+ throw new ArgumentNullException ( nameof ( queue ) ) ;
53
55
}
54
56
else
55
57
{
56
- Queue = queue ;
58
+ if ( queue == string . Empty )
59
+ {
60
+ Queue = _model . CurrentQueue ;
61
+ }
62
+ else
63
+ {
64
+ Queue = queue ;
65
+ }
57
66
}
58
67
59
68
if ( string . IsNullOrEmpty ( consumerTag ) )
@@ -66,20 +75,23 @@ public RecordedConsumer(AutorecoveringModel model, string queue, string consumer
66
75
}
67
76
}
68
77
69
- 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 ; }
70
85
public IDictionary < string , object > Arguments { get ; set ; }
71
86
public bool AutoAck { get ; set ; }
72
- public IBasicConsumer Consumer { get ; set ; }
73
- public string ConsumerTag { get ; set ; }
74
87
public bool Exclusive { get ; set ; }
75
- public string Queue { get ; set ; }
88
+ public IBasicConsumer Consumer { get ; set ; }
76
89
77
90
public string Recover ( IModel channelToUse )
78
91
{
79
92
ConsumerTag = channelToUse . BasicConsume ( Queue , AutoAck ,
80
93
ConsumerTag , false , Exclusive ,
81
94
Arguments , Consumer ) ;
82
-
83
95
return ConsumerTag ;
84
96
}
85
97
@@ -101,29 +113,10 @@ public RecordedConsumer WithConsumer(IBasicConsumer value)
101
113
return this ;
102
114
}
103
115
104
- public RecordedConsumer WithConsumerTag ( string value )
105
- {
106
- if ( string . IsNullOrEmpty ( value ) )
107
- {
108
- throw new System . ArgumentNullException ( nameof ( value ) ) ;
109
- }
110
- else
111
- {
112
- ConsumerTag = value ;
113
- }
114
- return this ;
115
- }
116
-
117
116
public RecordedConsumer WithExclusive ( bool value )
118
117
{
119
118
Exclusive = value ;
120
119
return this ;
121
120
}
122
-
123
- public RecordedConsumer WithQueue ( string value )
124
- {
125
- Queue = value ?? throw new System . ArgumentNullException ( nameof ( value ) ) ;
126
- return this ;
127
- }
128
121
}
129
122
}
0 commit comments