@@ -20,6 +20,7 @@ private enum PauseStatus
2020 PAUSED ,
2121 }
2222
23+ private readonly AmqpConnection _amqpConnection ;
2324 private readonly Guid _id = Guid . NewGuid ( ) ;
2425
2526 private ReceiverLink ? _receiverLink ;
@@ -28,10 +29,12 @@ private enum PauseStatus
2829 private readonly UnsettledMessageCounter _unsettledMessageCounter = new ( ) ;
2930 private readonly ConsumerConfiguration _configuration ;
3031
31- internal AmqpConsumer ( ConsumerConfiguration configuration )
32+ internal AmqpConsumer ( AmqpConnection amqpConnection , ConsumerConfiguration configuration )
3233 {
34+ _amqpConnection = amqpConnection ;
3335 _configuration = configuration ;
34- _configuration . Connection . AddConsumer ( _id , this ) ;
36+
37+ _amqpConnection . AddConsumer ( _id , this ) ;
3538 }
3639
3740 public override async Task OpenAsync ( )
@@ -74,7 +77,7 @@ void onAttached(ILink argLink, Attach argAttach)
7477 ReceiverLink ? tmpReceiverLink = null ;
7578 Task receiverLinkTask = Task . Run ( async ( ) =>
7679 {
77- Session session = await _configuration . Connection . _nativePubSubSessions . GetOrCreateSessionAsync ( )
80+ Session session = await _amqpConnection . _nativePubSubSessions . GetOrCreateSessionAsync ( )
7881 . ConfigureAwait ( false ) ;
7982 tmpReceiverLink = new ReceiverLink ( session , _id . ToString ( ) , attach , onAttached ) ;
8083 } ) ;
@@ -250,14 +253,14 @@ await _receiverLink.CloseAsync(TimeSpan.FromSeconds(5))
250253
251254 _receiverLink = null ;
252255 OnNewStatus ( State . Closed , null ) ;
253- _configuration . Connection . RemoveConsumer ( _id ) ;
256+ _amqpConnection . RemoveConsumer ( _id ) ;
254257 }
255258
256259 public override string ToString ( )
257260 {
258261 return $ "Consumer{{Address='{ _configuration . Address } ', " +
259262 $ "id={ _id } , " +
260- $ "Connection='{ _configuration . Connection } ', " +
263+ $ "Connection='{ _amqpConnection } ', " +
261264 $ "State='{ State } '}}";
262265 }
263266 }
0 commit comments