I have had a number of situations where I need a timer to fire in at a point in the future to trigger a workflow.
At the moment the only solutions I can come up with convoluted or require some external service.
The simplest way to achieve this is to use an Edge Agent that also has REDIS installed on the same host, and subscribe to events. Then if I need a workflow to trigger in 10mins, set an expiry time on a REDIS value, and set redis to provide Keyspace notifications.
The based on some criteria set a value with the desired expiry time, and then have a workflow subscribe to the event.
Unfortunately this doesn’t work in cloud workflows as we can’t subscribe to REDIS Pub/Sub.
Other schemes I have come up with cloud workflows, include
- Use the Edge Agent to send an appropriate data, or call API in Losant, as a result of the above local Redis key Expiry.
- define timeout, and start time in a Datatable, then have a workflow run every 30 seconds with a timer, that queries recent data table records and checks for timeout duration expiration.
Neither seem particularly elegant.
May be you could generalise the REDIS key expiry mechanism as a general purpose timed event generator for cloud workflows ?