Using the 'time' field in PutEventsRequestEntry to schedule events

1

I'm currently using another cloud provider to provide a service bus with flexible scheduling of messages because of the 15 minute maximum delay on SQS messages. I'm wondering if I can use EventBridge for my use case, so a couple of questions:

  1. Are there any restrictions on the 'time' field in PutEventsRequestEntry (https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutEventsRequestEntry.html)? Eg. is a timestamp in an hour supported? A timestamp next week? Next year?

  2. Is there any way to view/manage/cancel events that have been submitted using PutEvents (https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutEvents.html)? The most important is cancelling - if I send an event using PutEvents with a future time, is there anything I can use to later cancel that event from firing? Is there a way to view all events that have been scheduled in an event bus for a future time?

It'd be great to not have the complexity of using another cloud provider for this part of our app, and EventBridge looks like the closest thing AWS might have to the same service. Is this sort of use case supported?

Thanks!
Callum

CallumM
已提问 5 年前1645 查看次数
3 回答
1

Thanks for your question!

  1. Unfortunately the time field in PutEventsRequestEntry is not used for event scheduling, and does not affect when the event will be delivered to either the event bus, or the Target of any Rule you have created on that event bus. It is there, as part of a standardized set of metadata for event producers to use to describe events.

The delay feature is an interesting one. Could you tell us more about your use case to help us understand how we can best consider addressing it in our roadmap?

In general, if you are interested in scheduling messages in the future, one way to do that in AWS is to use the Scheduled Events: https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html

Using this feature, you can configure a Lambda function to be executed in the future, or on a recurring schedule. That Lambda function could in turn put messages on an SQS queue or PutEvents onto an Amazon EventBridge event bus.

  1. Currently, there is no way to manage events that have been submitted using PutEvents. However, as events are only processed if a Rule is created for the event bus, with a target, one option available for "cancelling" events is to temporarily disable the rule handling them. But I don't think that's what you had in mind, given that the context of the question was about scheduling events in the future.
AWS
已回答 5 年前
0

Hey, thanks for your reply! :)

My use case is essentially for scheduling API calls against our app that admins would otherwise have to make manually. We run surveys, so when a survey is created we can schedule the API calls to launch/close/publish etc. - these events are generally a few days from when we're scheduling them.

Currently we use Azure's service bus, which lets us (using their AMQP API) submit a task with an arbitrary timestamp at which it'll appear. This API returns a cancellation token that we can save in our database and use to cancel the task so it won't run, if we need to. In the same way as AWS SQS -> Lambda triggers, their service bus can trigger their equivalent of a Lambda, which can then make the appropriate API request described by the queued task.

In an ideal world we'd bring this into AWS, but I'm not aware of any service in AWS that can schedule a Lambda to run with the given data at an arbitrary future time, and in such a way that we can cancel it any time before then. Could CloudWatch events that you linked to be used for this purpose?

Thanks!
Callum

CallumM
已回答 5 年前
0

Answering my own question here, this can be done using AWS step functions - as long as the task is to run within the next year. We can use a 'delay until timestamp' step and then have the Lambda called (eg. by API or SQS) in the step after that.

CallumM
已回答 4 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则