Azure Service Bus使用消息内容或消息头数据调度消息取消 [英] Azure Service Bus Schedules Messages cancellation using the message content or message header data
问题描述
我想使用消息内容取消服务总线queue/topic
中的计划消息.
I would like to cancel the scheduled messages in the service bus queue/topic
using the message content.
例如:queue/topic
中的预定消息将类似于{UserName:'Scott', Test: 'This is test msg'}
e.g: the scheduled message in queue/topic
will be like this {UserName:'Scott', Test: 'This is test msg'}
我想使用UserName
注意:我没有保存取消令牌,可以用来取消计划的消息.
Note: I am not saving the cancellation token, which i can use to cancel the scheduled message.
推荐答案
AFAIK,无法基于用户属性取消计划的消息.您唯一可以取消预定消息的方法是通过它的SequenceNumber
属性.
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.
感谢肖恩·费尔德曼(Sean Feldman)的 blog post
关于同一主题,如果您知道邮件的SequenceNumber
属性,请按照以下方法取消预定的邮件:
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);
这篇关于Azure Service Bus使用消息内容或消息头数据调度消息取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!