Azure Service Bus Schedules Messages cancellation using the message content or message header data

拟墨画扇 提交于 2020-05-17 05:32:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!