- 最新
- 投票最多
- 评论最多
Thanks for your question!
- 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.
- 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.
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
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.