30
30
//---------------------------------------------------------------------------
31
31
32
32
using System ;
33
- using System . Buffers . Binary ;
34
33
using System . Collections . Generic ;
35
34
using System . Diagnostics ;
36
35
using System . Diagnostics . CodeAnalysis ;
@@ -602,8 +601,7 @@ await _basicAcksAsyncWrapper.InvokeAsync(this, args)
602
601
. ConfigureAwait ( false ) ;
603
602
}
604
603
605
- await HandleAck ( ack . _deliveryTag , ack . _multiple , cancellationToken )
606
- . ConfigureAwait ( false ) ;
604
+ HandleAck ( ack . _deliveryTag , ack . _multiple ) ;
607
605
608
606
return true ;
609
607
}
@@ -620,8 +618,7 @@ await _basicNacksAsyncWrapper.InvokeAsync(this, args)
620
618
. ConfigureAwait ( false ) ;
621
619
}
622
620
623
- await HandleNack ( nack . _deliveryTag , nack . _multiple , false , cancellationToken )
624
- . ConfigureAwait ( false ) ;
621
+ HandleNack ( nack . _deliveryTag , nack . _multiple , false ) ;
625
622
626
623
return true ;
627
624
}
@@ -640,19 +637,7 @@ await _basicReturnAsyncWrapper.InvokeAsync(this, e)
640
637
. ConfigureAwait ( false ) ;
641
638
}
642
639
643
- if ( _publisherConfirmationsEnabled )
644
- {
645
- ulong publishSequenceNumber = 0 ;
646
- IReadOnlyBasicProperties props = e . BasicProperties ;
647
- object ? maybeSeqNum = props . Headers ? [ Constants . PublishSequenceNumberHeader ] ;
648
- if ( maybeSeqNum != null )
649
- {
650
- publishSequenceNumber = BinaryPrimitives . ReadUInt64BigEndian ( ( byte [ ] ) maybeSeqNum ) ;
651
- }
652
-
653
- await HandleNack ( publishSequenceNumber , multiple : false , isReturn : true , cancellationToken )
654
- . ConfigureAwait ( false ) ;
655
- }
640
+ HandleReturn ( e ) ;
656
641
657
642
return true ;
658
643
}
@@ -1716,61 +1701,6 @@ await ModelSendAsync(in method, k.CancellationToken)
1716
1701
}
1717
1702
}
1718
1703
1719
- private Task HandleAck ( ulong deliveryTag , bool multiple , CancellationToken cancellationToken = default )
1720
- {
1721
- if ( _publisherConfirmationsEnabled && _publisherConfirmationTrackingEnabled && deliveryTag > 0 && ! _confirmsTaskCompletionSources . IsEmpty )
1722
- {
1723
- if ( multiple )
1724
- {
1725
- foreach ( KeyValuePair < ulong , TaskCompletionSource < bool > > pair in _confirmsTaskCompletionSources )
1726
- {
1727
- if ( pair . Key <= deliveryTag )
1728
- {
1729
- pair . Value . SetResult ( true ) ;
1730
- _confirmsTaskCompletionSources . Remove ( pair . Key , out _ ) ;
1731
- }
1732
- }
1733
- }
1734
- else
1735
- {
1736
- if ( _confirmsTaskCompletionSources . TryRemove ( deliveryTag , out TaskCompletionSource < bool > ? tcs ) )
1737
- {
1738
- tcs . SetResult ( true ) ;
1739
- }
1740
- }
1741
- }
1742
-
1743
- return Task . CompletedTask ;
1744
- }
1745
-
1746
- private Task HandleNack ( ulong deliveryTag , bool multiple , bool isReturn ,
1747
- CancellationToken cancellationToken = default )
1748
- {
1749
- if ( _publisherConfirmationsEnabled && _publisherConfirmationTrackingEnabled && deliveryTag > 0 && ! _confirmsTaskCompletionSources . IsEmpty )
1750
- {
1751
- if ( multiple )
1752
- {
1753
- foreach ( KeyValuePair < ulong , TaskCompletionSource < bool > > pair in _confirmsTaskCompletionSources )
1754
- {
1755
- if ( pair . Key <= deliveryTag )
1756
- {
1757
- pair . Value . SetException ( new PublishException ( pair . Key , isReturn ) ) ;
1758
- _confirmsTaskCompletionSources . Remove ( pair . Key , out _ ) ;
1759
- }
1760
- }
1761
- }
1762
- else
1763
- {
1764
- if ( _confirmsTaskCompletionSources . Remove ( deliveryTag , out TaskCompletionSource < bool > ? tcs ) )
1765
- {
1766
- tcs . SetException ( new PublishException ( deliveryTag , isReturn ) ) ;
1767
- }
1768
- }
1769
- }
1770
-
1771
- return Task . CompletedTask ;
1772
- }
1773
-
1774
1704
private BasicProperties ? PopulateBasicPropertiesHeaders < TProperties > ( TProperties basicProperties ,
1775
1705
Activity ? sendActivity , ulong publishSequenceNumber )
1776
1706
where TProperties : IReadOnlyBasicProperties , IAmqpHeader
0 commit comments