44 using System . Collections . Generic ;
55 using System . Diagnostics . Metrics ;
66 using System . Linq ;
7+ using System . Threading ;
78 using System . Threading . Tasks ;
89 using Infrastructure . Settings ;
910 using Monitoring ;
@@ -43,15 +44,15 @@ ITransportCustomization transportCustomization
4344 ) ;
4445 }
4546
46- public async Task Ingest ( List < MessageContext > contexts )
47+ public async Task Ingest ( List < MessageContext > contexts , CancellationToken cancellationToken )
4748 {
48- var stored = await auditPersister . Persist ( contexts ) ;
49+ var stored = await auditPersister . Persist ( contexts , cancellationToken ) ;
4950
5051 try
5152 {
5253 if ( settings . ForwardAuditMessages )
5354 {
54- await Forward ( stored , logQueueAddress ) ;
55+ await Forward ( stored , logQueueAddress , cancellationToken ) ;
5556 forwardedMessagesCounter . Add ( stored . Count ) ;
5657 }
5758
@@ -69,7 +70,7 @@ public async Task Ingest(List<MessageContext> contexts)
6970 }
7071 }
7172
72- Task Forward ( IReadOnlyCollection < MessageContext > messageContexts , string forwardingAddress )
73+ Task Forward ( IReadOnlyCollection < MessageContext > messageContexts , string forwardingAddress , CancellationToken cancellationToken )
7374 {
7475 var transportOperations = new TransportOperation [ messageContexts . Count ] ; //We could allocate based on the actual number of ProcessedMessages but this should be OK
7576 var index = 0 ;
@@ -98,12 +99,11 @@ Task Forward(IReadOnlyCollection<MessageContext> messageContexts, string forward
9899 return anyContext != null
99100 ? messageDispatcher . Value . Dispatch (
100101 new TransportOperations ( transportOperations ) ,
101- anyContext . TransportTransaction
102- )
102+ anyContext . TransportTransaction , cancellationToken )
103103 : Task . CompletedTask ;
104104 }
105105
106- public async Task VerifyCanReachForwardingAddress ( )
106+ public async Task VerifyCanReachForwardingAddress ( CancellationToken cancellationToken )
107107 {
108108 if ( ! settings . ForwardAuditMessages )
109109 {
@@ -120,7 +120,7 @@ public async Task VerifyCanReachForwardingAddress()
120120 )
121121 ) ;
122122
123- await messageDispatcher . Value . Dispatch ( transportOperations , new TransportTransaction ( ) ) ;
123+ await messageDispatcher . Value . Dispatch ( transportOperations , new TransportTransaction ( ) , cancellationToken ) ;
124124 }
125125 catch ( Exception e )
126126 {
0 commit comments