Clojure agents consuming from a queue

后端 未结 4 992
梦如初夏
梦如初夏 2020-12-13 04:41

I\'m trying to figure out the best way to use agents to consume items from a Message Queue (Amazon SQS). Right now I have a function (process-queue-item) that grabs an item

4条回答
  •  北海茫月
    2020-12-13 05:02

    Not sure how idiomatic this is, as I'm still a newbie with the language, but the following solution works for me:

    (let [number-of-messages-per-time 2
          await-timeout 1000]
      (doseq [p-messages (partition number-of-messages-per-time messages)]
        (let [agents (map agent p-messages)]
          (doseq [a agents] (send-off a process))
          (apply await-for await-timeout agents)
          (map deref agents))))
    

提交回复
热议问题