Azure服务总线队列:我可以管理/取消计划的消息吗? [英] Azure Service Bus Queue: Can I manage/cancel scheduled messages?

查看:100
本文介绍了Azure服务总线队列:我可以管理/取消计划的消息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我日后使用以下方式安排邮件:

If I schedule a message in the future using something like this:

d = datetime.utcnow() + timedelta(minutes=5)
task = {"some": "object"}

sbs.send_queue_message(
    qn,
    Message(
        task, 
        broker_properties={'ScheduledEnqueueTimeUtc': d}
    )
)

然后有什么方法可以查看/删除已安排的邮件? send_queue_message不返回任何内容,并且receive_queue_message不会返回计划在以后排队的项目-因此,例如,我无法掌握将其传递给delete_queue_message的情况.

Then is there a way that I can view/delete messages that have been scheduled? send_queue_message doesn't return anything, and receive_queue_message understandably doesn't return items that are scheduled to be queued later - so I can't get hold of it to pass to delete_queue_message for example.

Azure团队似乎意识到了用例,因为存储队列似乎具有这种功能: https://azure.microsoft.com/en-gb/blog/azure-storage-queues-new-feature-pop-receipt -on-add-message/

The Azure team seem aware of the usecase because Storage Queues seem to have something like this feature: https://azure.microsoft.com/en-gb/blog/azure-storage-queues-new-feature-pop-receipt-on-add-message/

基本上,我需要能够安排稍后要排队的消息,但是可以取消此消息.理想情况下,我希望还可以查看所有将来计划的任务,但是仅存储一个ID(以后可用来删除排队的消息)就足够了.

Basically I need to be able to schedule a message to be queued later, but have this cancelable. Ideally I'd like to be able to also view all future scheduled tasks, but being able to just store an id that can be used to later delete the queued message would be sufficient.

Azure UI也显示了活动/计划的邮件的数量,这似乎表明应该有某种方式可以查看这些计划的邮件!

The Azure UI shows the count of active/scheduled messages too, which seems to suggest there should be some way to see those scheduled ones!

队列存储会更好吗?还是服务总线有某种可行的方法? ScheduledEnqueueTimeUtc似乎比队列存储中的可见性超时更灵活,因此,如果可以的话,最好坚持一下.

Would queue storage be better for this? Or does service bus have some approach that might work? ScheduledEnqueueTimeUtc seems more flexible than the visibility timeout in queue storage so it'd be nice to stick with it if I can.

推荐答案

是的,有可能.

不知道NodeJS客户端是否支持它,但是对于C#客户端,我已经描述了

Don't know if NodeJS client has support for it or not, but with C# client there's an alternative to ScheduledEnqueueTimeUtc approach I've described here. Using QueueClient.ScheduleMessageAsync() you can send a scheduled message and get the SequenceNumber. Which then can be used to cancel the message at any point in time using QueueClient.CancelScheduledMessageAsync(sequenceNumber).

这篇关于Azure服务总线队列:我可以管理/取消计划的消息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆