Hey folks, been digging and experimenting on this for quite a while. Not having much luck on forums or my testing.
Scenario:
- A DB Trigger in my app will initiate an API call to a 3rd party.
- I can get a bunch of these triggers simultaneously.
- I’d like to limit how frequently I hit this 3rd party API (1 minute in-between each call).
- This is basic queueing, but I can’t seem to get this working well in Bubble.
Test #1:
- For each DB trigger, I would set a “Last Date” to a “Queue” table.
- I would use that date (plus 1 minute) as the schedule time to run the API Workflow that calls the 3rd party API.
- I would then set the Last Date in the Queue table to the new value (i.e. plus 1 minute).
In theory each trigger would push the API call out one minute past the last one scheduled. The problem is that they come in too quick and the DB calls to “Last Date” don’t update fast enough. So they all get scheduled simultaneously.
Test #2:
- The DB Trigger adds an entry into a “Queue” table (has “User” and “Run Date” fields).
- The “Run Date” is essentially set to (1 minute) x (count-of-records-in-the-queue). This works pretty well with the occasional overlap of a record or few.
- Set up another DB Trigger to watch for new entries in “Queue”, schedule the API call based on the Run Date field.
In theory, this would work great. Except after building it I found a note in the Bubble docs that says a DB Trigger cannot initiate another DB Trigger.
Insert audible sigh here
Anyone have any best practices on how to do this? I feel like there’s a simple and elegant solution I’m missing somewhere.
THANK YOU!
Al