@@ -40,20 +40,20 @@ public AmazonSqsClientContext(ConnectionContext connectionContext,
4040
4141 public ConnectionContext ConnectionContext { get ; }
4242
43- public Task < TopicInfo > CreateTopic ( Topology . Topic topic )
43+ public Task < TopicInfo > CreateTopic ( Topology . Topic topic , CancellationToken cancellationToken )
4444 {
45- return ConnectionContext . GetTopic ( topic ) ;
45+ return ConnectionContext . GetTopic ( topic , cancellationToken ) ;
4646 }
4747
48- public Task < QueueInfo > CreateQueue ( Queue queue )
48+ public Task < QueueInfo > CreateQueue ( Queue queue , CancellationToken cancellationToken )
4949 {
50- return ConnectionContext . GetQueue ( queue ) ;
50+ return ConnectionContext . GetQueue ( queue , cancellationToken ) ;
5151 }
5252
53- public async Task < bool > CreateQueueSubscription ( Topology . Topic topic , Queue queue )
53+ public async Task < bool > CreateQueueSubscription ( Topology . Topic topic , Queue queue , CancellationToken cancellationToken )
5454 {
55- var topicInfo = await ConnectionContext . GetTopic ( topic ) . ConfigureAwait ( false ) ;
56- var queueInfo = await ConnectionContext . GetQueue ( queue ) . ConfigureAwait ( false ) ;
55+ var topicInfo = await ConnectionContext . GetTopic ( topic , cancellationToken ) . ConfigureAwait ( false ) ;
56+ var queueInfo = await ConnectionContext . GetQueue ( queue , cancellationToken ) . ConfigureAwait ( false ) ;
5757
5858 Dictionary < string , string > subscriptionAttributes = topic . TopicSubscriptionAttributes . MergeLeft ( queue . QueueSubscriptionAttributes )
5959 . ToDictionary ( x => x . Key , x => x . Value . ToString ( ) ! ) ;
@@ -69,7 +69,7 @@ public async Task<bool> CreateQueueSubscription(Topology.Topic topic, Queue queu
6969 string ? subscriptionArn = null ;
7070 try
7171 {
72- var response = await _snsClient . SubscribeAsync ( subscribeRequest , CancellationToken ) . ConfigureAwait ( false ) ;
72+ var response = await _snsClient . SubscribeAsync ( subscribeRequest , cancellationToken ) . ConfigureAwait ( false ) ;
7373
7474 response . EnsureSuccessfulResponse ( ) ;
7575
@@ -79,7 +79,7 @@ public async Task<bool> CreateQueueSubscription(Topology.Topic topic, Queue queu
7979 {
8080 try
8181 {
82- var existingSubscriptions = await _snsClient . ListSubscriptionsByTopicAsync ( topicInfo . Arn , CancellationToken ) . ConfigureAwait ( false ) ;
82+ var existingSubscriptions = await _snsClient . ListSubscriptionsByTopicAsync ( topicInfo . Arn , cancellationToken ) . ConfigureAwait ( false ) ;
8383 existingSubscriptions . EnsureSuccessfulResponse ( ) ;
8484
8585 var existingSubscription = existingSubscriptions . Subscriptions . SingleOrDefault ( x =>
@@ -88,7 +88,7 @@ public async Task<bool> CreateQueueSubscription(Topology.Topic topic, Queue queu
8888 if ( existingSubscription != null )
8989 {
9090 subscriptionArn = existingSubscription . SubscriptionArn ;
91- var attributes = await _snsClient . GetSubscriptionAttributesAsync ( subscriptionArn , CancellationToken )
91+ var attributes = await _snsClient . GetSubscriptionAttributesAsync ( subscriptionArn , cancellationToken )
9292 . ConfigureAwait ( false ) ;
9393
9494 if ( attributes . HttpStatusCode is >= HttpStatusCode . OK and < HttpStatusCode . MultipleChoices )
@@ -102,7 +102,7 @@ public async Task<bool> CreateQueueSubscription(Topology.Topic topic, Queue queu
102102 SubscriptionArn = subscriptionArn
103103 } ;
104104
105- var updated = await _snsClient . SetSubscriptionAttributesAsync ( request , CancellationToken ) . ConfigureAwait ( false ) ;
105+ var updated = await _snsClient . SetSubscriptionAttributesAsync ( request , cancellationToken ) . ConfigureAwait ( false ) ;
106106 updated . EnsureSuccessfulResponse ( ) ;
107107
108108 LogContext . Debug ? . Log ( "Updated subscription attribute: {SubscriptionArn} {Name}={Value}" , subscriptionArn , name ,
@@ -124,36 +124,36 @@ public async Task<bool> CreateQueueSubscription(Topology.Topic topic, Queue queu
124124
125125 var sqsQueueArn = queueInfo . Arn ;
126126
127- return await queueInfo . UpdatePolicy ( sqsQueueArn , topicInfo . Arn , CancellationToken ) . ConfigureAwait ( false ) ;
127+ return await queueInfo . UpdatePolicy ( sqsQueueArn , topicInfo . Arn , cancellationToken ) . ConfigureAwait ( false ) ;
128128 }
129129
130- public async Task DeleteTopic ( Topology . Topic topic )
130+ public async Task DeleteTopic ( Topology . Topic topic , CancellationToken cancellationToken )
131131 {
132- var topicInfo = await ConnectionContext . GetTopic ( topic ) . ConfigureAwait ( false ) ;
132+ var topicInfo = await ConnectionContext . GetTopic ( topic , cancellationToken ) . ConfigureAwait ( false ) ;
133133
134134 TransportLogMessages . DeleteTopic ( topicInfo . Arn ) ;
135135
136- var response = await _snsClient . DeleteTopicAsync ( topicInfo . Arn , CancellationToken . None ) . ConfigureAwait ( false ) ;
136+ var response = await _snsClient . DeleteTopicAsync ( topicInfo . Arn , cancellationToken ) . ConfigureAwait ( false ) ;
137137
138138 response . EnsureSuccessfulResponse ( ) ;
139139
140140 await ConnectionContext . RemoveTopicByName ( topic . EntityName ) . ConfigureAwait ( false ) ;
141141 }
142142
143- public async Task DeleteQueue ( Queue queue )
143+ public async Task DeleteQueue ( Queue queue , CancellationToken cancellationToken )
144144 {
145- var queueInfo = await ConnectionContext . GetQueue ( queue ) . ConfigureAwait ( false ) ;
145+ var queueInfo = await ConnectionContext . GetQueue ( queue , cancellationToken ) . ConfigureAwait ( false ) ;
146146
147147 TransportLogMessages . DeleteQueue ( queueInfo . Url ) ;
148148
149149 foreach ( var subscriptionArn in queueInfo . SubscriptionArns )
150150 {
151151 TransportLogMessages . DeleteSubscription ( queueInfo . Url , subscriptionArn ) ;
152152
153- await DeleteQueueSubscription ( subscriptionArn ) . ConfigureAwait ( false ) ;
153+ await DeleteQueueSubscription ( subscriptionArn , cancellationToken ) . ConfigureAwait ( false ) ;
154154 }
155155
156- var response = await _sqsClient . DeleteQueueAsync ( queueInfo . Url , CancellationToken . None ) . ConfigureAwait ( false ) ;
156+ var response = await _sqsClient . DeleteQueueAsync ( queueInfo . Url , cancellationToken ) . ConfigureAwait ( false ) ;
157157
158158 response . EnsureSuccessfulResponse ( ) ;
159159
@@ -162,28 +162,28 @@ public async Task DeleteQueue(Queue queue)
162162
163163 public async Task Publish ( string topicName , PublishBatchRequestEntry request , CancellationToken cancellationToken )
164164 {
165- var topicInfo = await ConnectionContext . GetTopicByName ( topicName ) . ConfigureAwait ( false ) ;
165+ var topicInfo = await ConnectionContext . GetTopicByName ( topicName , cancellationToken ) . ConfigureAwait ( false ) ;
166166
167167 await topicInfo . Publish ( request , cancellationToken ) . ConfigureAwait ( false ) ;
168168 }
169169
170170 public async Task SendMessage ( string queueName , SendMessageBatchRequestEntry request , CancellationToken cancellationToken )
171171 {
172- var queueInfo = await ConnectionContext . GetQueueByName ( queueName ) . ConfigureAwait ( false ) ;
172+ var queueInfo = await ConnectionContext . GetQueueByName ( queueName , cancellationToken ) . ConfigureAwait ( false ) ;
173173
174174 await queueInfo . Send ( request , cancellationToken ) . ConfigureAwait ( false ) ;
175175 }
176176
177177 public async Task DeleteMessage ( string queueName , string receiptHandle , CancellationToken cancellationToken )
178178 {
179- var queueInfo = await ConnectionContext . GetQueueByName ( queueName ) . ConfigureAwait ( false ) ;
179+ var queueInfo = await ConnectionContext . GetQueueByName ( queueName , cancellationToken ) . ConfigureAwait ( false ) ;
180180
181181 await queueInfo . Delete ( receiptHandle , cancellationToken ) . ConfigureAwait ( false ) ;
182182 }
183183
184184 public async Task PurgeQueue ( string queueName , CancellationToken cancellationToken )
185185 {
186- var queueInfo = await ConnectionContext . GetQueueByName ( queueName ) . ConfigureAwait ( false ) ;
186+ var queueInfo = await ConnectionContext . GetQueueByName ( queueName , cancellationToken ) . ConfigureAwait ( false ) ;
187187
188188 var response = await _sqsClient . PurgeQueueAsync ( queueInfo . Url , cancellationToken ) . ConfigureAwait ( false ) ;
189189
@@ -192,7 +192,7 @@ public async Task PurgeQueue(string queueName, CancellationToken cancellationTok
192192
193193 public async Task < IList < Message > > ReceiveMessages ( string queueName , int messageLimit , int waitTime , CancellationToken cancellationToken )
194194 {
195- var queueInfo = await ConnectionContext . GetQueueByName ( queueName ) . ConfigureAwait ( false ) ;
195+ var queueInfo = await ConnectionContext . GetQueueByName ( queueName , cancellationToken ) . ConfigureAwait ( false ) ;
196196
197197 var request = new ReceiveMessageRequest ( queueInfo . Url )
198198 {
@@ -211,28 +211,28 @@ public async Task<IList<Message>> ReceiveMessages(string queueName, int messageL
211211 return response . Messages ?? new List < Message > ( ) ;
212212 }
213213
214- public Task < QueueInfo > GetQueueInfo ( string queueName )
214+ public Task < QueueInfo > GetQueueInfo ( string queueName , CancellationToken cancellationToken )
215215 {
216- return ConnectionContext . GetQueueByName ( queueName ) ;
216+ return ConnectionContext . GetQueueByName ( queueName , cancellationToken ) ;
217217 }
218218
219- public async Task ChangeMessageVisibility ( string queueUrl , string receiptHandle , int seconds )
219+ public async Task ChangeMessageVisibility ( string queueUrl , string receiptHandle , int seconds , CancellationToken cancellationToken )
220220 {
221221 var response = await _sqsClient . ChangeMessageVisibilityAsync ( new ChangeMessageVisibilityRequest
222222 {
223223 QueueUrl = queueUrl ,
224224 ReceiptHandle = receiptHandle ,
225225 VisibilityTimeout = seconds
226- } , CancellationToken ) . ConfigureAwait ( false ) ;
226+ } , cancellationToken ) . ConfigureAwait ( false ) ;
227227
228228 response . EnsureSuccessfulResponse ( ) ;
229229 }
230230
231- async Task DeleteQueueSubscription ( string subscriptionArn )
231+ async Task DeleteQueueSubscription ( string subscriptionArn , CancellationToken cancellationToken )
232232 {
233233 var unsubscribeRequest = new UnsubscribeRequest { SubscriptionArn = subscriptionArn } ;
234234
235- var response = await _snsClient . UnsubscribeAsync ( unsubscribeRequest , CancellationToken . None ) . ConfigureAwait ( false ) ;
235+ var response = await _snsClient . UnsubscribeAsync ( unsubscribeRequest , cancellationToken ) . ConfigureAwait ( false ) ;
236236
237237 response . EnsureSuccessfulResponse ( ) ;
238238 }
0 commit comments