延迟消息处理并在处理之前删除 [英] Delay message processing and delete before processing

查看:73
本文介绍了延迟消息处理并在处理之前删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要这种能力来发送针对移动应用中某项操作的推送通知,但要等到用户撤消该操作,直到说10秒钟.

I need this ability to send push notifications for an action in a mobile app but wait for the user to undo the action until say 10 seconds.

是否可以将主题中发布的消息的处理延迟10秒?然后(有时,如果用户撤消操作)在10秒钟之前删除该消息,是否不需要处理?

Is it possible to delay the processing of a message published in a topic by 10 seconds ? And then (sometimes, if user does undo) delete the message before 10 seconds, if it doesn't need to be processed ?

推荐答案

取决于是否也写订阅者:

Depends on if you write the subscribers as well or not:

您可以控制您的订阅者代码:

You have control over your subscribers code:

  1. 在您的Pubsub消息中添加时间戳记 待处理的邮件.
  2. 在您的客户(订户)中,有逻辑地 仅在处理消息的时间戳记时才确认消息 达到了.
  3. Pubsub本身将重试传递消息,直到 被确认(或10天)
  1. In your Pubsub messages add a timestamp for when you want that message to be processed.
  2. In your clients (subscribers), have logic to acknowledge the message only if the timestamp to process the message is reached.
  3. Pubsub itself will re-try delivering the message until it's acknowledged (or 10 days)

如果您无法控制订户,则可以拥有一个my-topic和my-delayed-topic.人们可以将其发布到前一个主题,而该主题将只有一个订阅者,您将实现该订阅者:

If you don't have control over your subscriber you can have a my-topic and my-delayed-topic. Folks can publish to the former topic and that topic will have only one subscriber which you will implement:

  1. 向我的主题发送公开消息.
  2. ,该主题的订阅者可以进行与上述相同的调节:
  3. 如果该消息的时间已到,您的处理程序将将该消息发布/中继到my-delayed-topic.
  1. Public message as before to my-topic.
  2. You will have a subscriber for that topic that can do the same throttling as shown above:
  3. If the time for that message has reached your handler will publish/relay that message to my-delayed-topic.

您还可以使用task-queue + pubsub-topic而不是pubsub-topic + pubsub-topic来实现上述逻辑.

You can also implement the logic above with task-queue+pubsub-topic instead of pubsub-topic+pubsub-topic.

这篇关于延迟消息处理并在处理之前删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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