@@ -36,24 +36,33 @@ namespace RabbitMQ.Client.Impl
3636{
3737 internal class RecordedConsumer : IRecordedConsumer
3838 {
39+ private readonly AutorecoveringModel _model ;
40+
3941 public RecordedConsumer ( AutorecoveringModel model , string queue , string consumerTag )
4042 {
41- if ( model == null )
43+ if ( model is null )
4244 {
4345 throw new ArgumentNullException ( nameof ( model ) ) ;
4446 }
4547 else
4648 {
47- Model = model ;
49+ _model = model ;
4850 }
4951
50- if ( string . IsNullOrEmpty ( queue ) )
52+ if ( queue is null )
5153 {
52- throw new ArgumentNullException ( nameof ( consumerTag ) ) ;
54+ throw new ArgumentNullException ( nameof ( queue ) ) ;
5355 }
5456 else
5557 {
56- Queue = queue ;
58+ if ( queue == string . Empty )
59+ {
60+ Queue = _model . CurrentQueue ;
61+ }
62+ else
63+ {
64+ Queue = queue ;
65+ }
5766 }
5867
5968 if ( string . IsNullOrEmpty ( consumerTag ) )
@@ -66,20 +75,23 @@ public RecordedConsumer(AutorecoveringModel model, string queue, string consumer
6675 }
6776 }
6877
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 ; }
7085 public IDictionary < string , object > Arguments { get ; set ; }
7186 public bool AutoAck { get ; set ; }
72- public IBasicConsumer Consumer { get ; set ; }
73- public string ConsumerTag { get ; set ; }
7487 public bool Exclusive { get ; set ; }
75- public string Queue { get ; set ; }
88+ public IBasicConsumer Consumer { get ; set ; }
7689
7790 public string Recover ( IModel channelToUse )
7891 {
7992 ConsumerTag = channelToUse . BasicConsume ( Queue , AutoAck ,
8093 ConsumerTag , false , Exclusive ,
8194 Arguments , Consumer ) ;
82-
8395 return ConsumerTag ;
8496 }
8597
@@ -101,29 +113,10 @@ public RecordedConsumer WithConsumer(IBasicConsumer value)
101113 return this ;
102114 }
103115
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-
117116 public RecordedConsumer WithExclusive ( bool value )
118117 {
119118 Exclusive = value ;
120119 return this ;
121120 }
122-
123- public RecordedConsumer WithQueue ( string value )
124- {
125- Queue = value ?? throw new System . ArgumentNullException ( nameof ( value ) ) ;
126- return this ;
127- }
128121 }
129122}
0 commit comments