https://slingdata.io logo
m
@flarco Hi! I'm trying to use queues in the API spec to iterate over multiple fields but couldn't find any examples on how to achieve this. I have a few related questions: 1. Iterating with multiple queues I have a producer endpoint that pushes values into two queues:
Copy code
yaml
processors:
  - expression: "record.branch_id"
    output: "queue.branch_ids"
  - expression: "record.restaurant_id"
    output: "queue.restaurant_ids"
And a consumer endpoint that tries to iterate over both:
Copy code
yaml
iterate:
  over: object("branch_id", queue.branch_ids, "restaurant_id", queue.restaurant_ids)
  into: "state.branch_spec"
This gives the error:
loop expression is not an array or a queue
Is there a supported way to iterate over multiple queues in parallel (pairing values by index), or does
iterate.over
only support a single queue/array? The consumer endpoint also returns arrays per record that I need to flatten into individual iterations. 2. Limiting queue consumption When using
limit
on the consumer endpoint, it seems to only limit the rows written to the target table — the queue still gets fully consumed. Is there a way to limit how many items are dequeued and iterated over, not just how many rows are inserted? 3. Adding a fixed delay between requests in a loop Is there a way to define a minimum wait/sleep between each request in an iterated endpoint? The
rate
attribute controls max requests per second, but I need the opposite — a guaranteed pause between requests (e.g. 1 request every 5 seconds). We're working with a very rate-limited API and need finer control over request pacing. Thanks!
f
hey @MarikT94 1. Yeah, that's not going to work, the
iterate.over
needs to be iterable, you're providing an object. An alternative could be to push both into the same queue as records?
Copy code
yaml
processors:
  - expression: "object("branch_id", record.branch_id)"
    output: "queue.branch_spec_records"
  - expression: "object("restaurant_id", record.restaurant_id)"
    output: "queue.branch_spec_records"
Copy code
yaml
iterate:
  over: queue.branch_spec_records
  into: "state.branch_spec_record"
then you can access which ever with
state.branch_spec_record.branch_id
or
state.branch_spec_record.restaurant_id
2. That a good point, let me look into adding that. 3. The
rate
accepts decimals, can you try
rate: 0.2
?
m
1. Yes, I tried both methoda actually as mentioned.. 2. Thanks, let me know 🙏 for no we have solved it with loops over pipeline groups. 3. What 0.2 would mean?
f
rate: 0.2 mean 0.2 request per second, so 1 request every 5 sec
m
Ohh ok, it wasnt intuitive enough to me 😅
2 Views