44
55using System ;
66using System . Buffers ;
7- using System . Collections . Generic ;
8- using System . Threading . Tasks ;
97
108namespace RabbitMQ . Stream . Client
119{
1210 public readonly struct CreditResponse : ICommand
1311 {
1412 public const ushort Key = 9 ;
15- private readonly byte subscriptionId ;
16- private readonly ResponseCode responseCode ;
1713
1814 private CreditResponse ( ResponseCode responseCode , byte subscriptionId )
1915 {
20- this . subscriptionId = subscriptionId ;
21- this . responseCode = responseCode ;
16+ SubscriptionId = subscriptionId ;
17+ ResponseCode = responseCode ;
2218 }
2319
2420 public int SizeNeeded => throw new NotImplementedException ( ) ;
2521
26- public byte SubscriptionId => subscriptionId ;
22+ private byte SubscriptionId { get ; }
2723
28- public ResponseCode ResponseCode => responseCode ;
24+ private ResponseCode ResponseCode { get ; }
2925
3026 public int Write ( Span < byte > span )
3127 {
@@ -43,24 +39,17 @@ internal static int Read(ReadOnlySequence<byte> frame, out CreditResponse comman
4339 return offset ;
4440 }
4541
46- internal void HandleUnroutableCredit ( IDictionary < byte , Func < Deliver , Task > > consumers )
42+ internal void HandleUnRoutableCredit ( )
4743 {
48- /* the server sent a credit-response only in case of
44+ /* the server sends a credit-response only in case of
4945 * problem, e.g. crediting an unknown subscription
5046 * (which can happen when a consumer is closed at
5147 * the same time as the deliverhandler is working
5248 */
5349
54- if ( consumers . ContainsKey ( SubscriptionId ) && ResponseCode == ResponseCode . SubscriptionIdDoesNotExist )
55- {
56- LogEventSource . Log . LogWarning ( $ "Consumer subscription has been unregistered " +
57- $ "on the server whlie client was publishing credit command(s)") ;
58- }
59- else
60- {
61- throw new Exception ( $ "An unexpected { nameof ( CreditResponse ) } for subscriptionId " +
62- $ "{ SubscriptionId } was received with responsecode { ResponseCode } ") ;
63- }
50+ LogEventSource . Log . LogWarning (
51+ $ "Received notification for subscription id: { SubscriptionId } " +
52+ $ "code: { ResponseCode } ") ;
6453 }
6554 }
6655}
0 commit comments