Submission order and completion order differ
A queue should preserve the user's intended task and spending approval while waiting. It must not mark waiting work as already accepted by AISwapLab. Each item needs its own stable idempotency identifier, and an uncertain accepted item must remain traceable. A local claim or equivalent synchronization can prevent two application workers from dispatching the same item at once; that is your integration design, not a new AISwapLab queue endpoint.
What to do next
- 01
Persist the waiting tasks
Store payload, approval ceiling, account user and identifier before dispatch. Give waiting items a local queue state distinct from a returned provider-processing state.
- 02
Dispatch with backpressure
Start with one active worker per account and observe actual limits. Handle a concurrency 429 by leaving the item queued for a bounded later retry of the same intended task.
- 03
Reconcile active work
Poll accepted jobs centrally and release local slots when their states warrant it. Keep unknown work visible for reconciliation rather than counting only jobs with media previews.
A concrete example
Illustrative queue: ten approved image concepts wait in the application's database. The dispatcher submits one at a time, records each returned job, and pauses when the shared account is also processing a studio video.
Queue dispatch boundary
| Local state | Record or control | Remote implication |
|---|---|---|
| Waiting for capacity | Approved immutable task plus a local dispatch claim | Not yet accepted by AISwapLab |
| Creation sent or uncertain | Original identifier and send-attempt record | May already occupy shared active work |
| Accepted existing job | One central reconciler and durable job ID | Follow that job; do not release a slot merely because no preview exists |
Before you call it ready
- Waiting and accepted tasks are distinct.
- Each item has a stable request identifier.
- Studio activity is considered in shared capacity.
When to stop or choose another method
If throughput requirements exceed these current limits, do not promise instant batch output. Communicate queue behavior and obtain the appropriate supported capacity before selling the workflow.
