问题
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.
回答1:
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);
来源:https://stackoverflow.com/questions/61153962/azure-service-bus-schedules-messages-cancellation-using-the-message-content-or-m