@@ -145,7 +145,8 @@ private async Task<int> ExecuteResubmitAsync(
145145 string entityDescription ,
146146 CancellationToken cancellationToken )
147147 {
148- Output . Info ( $ "Resubmitting DLQ messages for { entityDescription } ...") ;
148+ var targetInfo = GetTargetInfo ( options ) ;
149+ Output . Info ( $ "Resubmitting DLQ messages for { entityDescription } { targetInfo } ...") ;
149150
150151 if ( options . BeforeEnqueueTime . HasValue )
151152 {
@@ -166,8 +167,9 @@ private async Task<int> ExecuteFullResubmitAsync(
166167 options . Topic ,
167168 options . Subscription ,
168169 ServiceBusReceiveMode . PeekLock ) ;
169- await using var sender = CreateSender ( client , options . Queue , options . Topic ) ;
170+ await using var sender = CreateSender ( client , options . EffectiveTarget ) ;
170171
172+ var targetInfo = GetTargetInfo ( options ) ;
171173 var totalResubmitted = 0 ;
172174 var emptyBatches = 0 ;
173175
@@ -196,7 +198,7 @@ private async Task<int> ExecuteFullResubmitAsync(
196198 }
197199
198200 Console . WriteLine ( ) ;
199- Output . Success ( $ "Resubmitted { totalResubmitted } messages from DLQ for { entityDescription } ") ;
201+ Output . Success ( $ "Resubmitted { totalResubmitted } messages from DLQ for { entityDescription } { targetInfo } ") ;
200202 return 0 ;
201203 }
202204
@@ -211,8 +213,9 @@ private async Task<int> ExecuteFilteredResubmitAsync(
211213 options . Topic ,
212214 options . Subscription ,
213215 ServiceBusReceiveMode . PeekLock ) ;
214- await using var sender = CreateSender ( client , options . Queue , options . Topic ) ;
216+ await using var sender = CreateSender ( client , options . EffectiveTarget ) ;
215217
218+ var targetInfo = GetTargetInfo ( options ) ;
216219 var totalResubmitted = 0 ;
217220 var totalSkipped = 0 ;
218221 var emptyBatches = 0 ;
@@ -267,7 +270,7 @@ private async Task<int> ExecuteFilteredResubmitAsync(
267270 }
268271
269272 Console . WriteLine ( ) ;
270- Output . Success ( $ "Resubmitted { totalResubmitted } messages from DLQ for { entityDescription } (skipped { totalSkipped } newer messages)") ;
273+ Output . Success ( $ "Resubmitted { totalResubmitted } messages from DLQ for { entityDescription } { targetInfo } (skipped { totalSkipped } newer messages)") ;
271274 return 0 ;
272275 }
273276
@@ -320,12 +323,13 @@ private async Task<int> ExecuteInteractiveResubmitAsync(
320323 totalToResubmit += cat . Count ;
321324 }
322325
323- Output . Info ( $ "Resubmitting { totalToResubmit } messages from { selectedIndices . Count } categories...") ;
326+ var targetInfo = GetTargetInfo ( options ) ;
327+ Output . Info ( $ "Resubmitting { totalToResubmit } messages from { selectedIndices . Count } categories{ targetInfo } ...") ;
324328
325329 var totalResubmitted = await ResubmitByCategoriesAsync ( client , options , selectedCategories , cancellationToken ) ;
326330
327331 Console . WriteLine ( ) ;
328- Output . Success ( $ "Resubmitted { totalResubmitted } messages from DLQ for { entityDescription } .") ;
332+ Output . Success ( $ "Resubmitted { totalResubmitted } messages from DLQ for { entityDescription } { targetInfo } .") ;
329333 return 0 ;
330334 }
331335
@@ -414,7 +418,7 @@ private async Task<int> ResubmitByCategoriesAsync(
414418 options . Topic ,
415419 options . Subscription ,
416420 ServiceBusReceiveMode . PeekLock ) ;
417- await using var sender = CreateSender ( client , options . Queue , options . Topic ) ;
421+ await using var sender = CreateSender ( client , options . EffectiveTarget ) ;
418422
419423 var totalResubmitted = 0 ;
420424 var totalSkipped = 0 ;
@@ -498,5 +502,17 @@ private static ServiceBusMessage CreateResubmitMessage(ServiceBusReceivedMessage
498502 return message ;
499503 }
500504
501- private static ServiceBusSender CreateSender ( ServiceBusClient client , string ? queueName , string ? topicName ) => client . CreateSender ( ! string . IsNullOrEmpty ( queueName ) ? queueName : topicName ! ) ;
505+ private static ServiceBusSender CreateSender ( ServiceBusClient client , string targetEntity ) => client . CreateSender ( targetEntity ) ;
506+
507+ private static string GetTargetInfo ( ResubmitDlqOptions options )
508+ {
509+ var hasCustomTarget = ! string . IsNullOrEmpty ( options . TargetQueue ) || ! string . IsNullOrEmpty ( options . TargetTopic ) ;
510+ if ( ! hasCustomTarget )
511+ {
512+ return string . Empty ;
513+ }
514+
515+ var targetType = ! string . IsNullOrEmpty ( options . TargetQueue ) ? "queue" : "topic" ;
516+ return $ " to { targetType } '{ options . EffectiveTarget } '";
517+ }
502518}
0 commit comments