1

I would like to cancel the scheduled messages in the service bus queue/topic using the message content.

e.g: the scheduled message in queue/topic will be like this {UserName:'Scott', Test: 'This is test msg'}

I would like to cancel the schedules message using the UserName

Note: I am not saving the cancellation token, which i can use to cancel the scheduled message.

Aymen TAGHLISSIA
  • 1,675
  • 13
  • 30
priyanka
  • 11
  • 1

1 Answers1

0

AFAIK, it is not possible to cancel a scheduled message based on a user property. Only way you could cancel a scheduled message is by it's SequenceNumber property.

Thanks to Sean Feldman for his blog post on the same topic, here's how you can cancel a scheduled message if you know the message's SequenceNumber property:

var sequenceNumber = await queueClient.ScheduleMessageAsync(message, DateTimeOffset.UtcNow.AddSeconds(300)).ConfigureAwait(false);
await queueClient.CancelScheduledMessageAsync(sequenceNumber).ConfigureAwait(false);
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241