This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-04
Channels
- # announcements (5)
- # aws (11)
- # babashka (15)
- # beginners (101)
- # biff (14)
- # calva (45)
- # clj-kondo (18)
- # cljs-dev (5)
- # clojure (178)
- # clojure-austin (5)
- # clojure-europe (8)
- # clojure-france (1)
- # clojure-nl (12)
- # clojure-norway (6)
- # clojure-spec (4)
- # clojure-uk (1)
- # clojurescript (13)
- # community-development (2)
- # conjure (6)
- # cursive (8)
- # datahike (1)
- # datalevin (3)
- # datascript (36)
- # datomic (6)
- # emacs (2)
- # etaoin (2)
- # fulcro (5)
- # graalvm (6)
- # gratitude (3)
- # introduce-yourself (1)
- # jobs-discuss (1)
- # lsp (19)
- # malli (4)
- # nbb (11)
- # off-topic (4)
- # other-languages (1)
- # pathom (19)
- # pedestal (1)
- # shadow-cljs (22)
- # spacemacs (16)
- # tools-deps (31)
- # vim (7)
are there any examples of aws sqs using cognitect aws-api?
I would like to reach out an example for retrieving messages from time to time
(require '[promesa.core :as p])
(defonce consume-sqs-scheduler-running
(atom true))
(def consume-sqs-scheduler
(let [{::keys [event-pull-seconds]} config]
(p/loop []
(p/delay (* 1000 event-pull-seconds))
(when @consume-sqs-scheduler-running
(handle-sqs-data (pull-sqs-data! config))
#_(println ::RUN!))
(p/recur))))
SQS client has built-in long-polling support if max 20sec interval is OK for you https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/examples-sqs-long-polling.html
Sorry, I don’t have an example how to use that with cognitect aws-api but just wanted to point out this as an option. 🙂
Oh wait… cognitect aws-api uses the API directly and there’s no “official” aws-client involved.. So you’ll probably need to build the delay mechanism yourself. Your example with promesa looks like a an OK starting point. It’s very simple and probably works. If you you need something more robust I’d look into quarts (maybe a bit overkill), tea-time or similar scheduler.
Or.. since you’re on AWS.. it’s also possible to schedule a lambda to periodically read the queue
Actually.. it would be kinda interesting if someone has figured out how to do long-polling with cognitect aws-api
I would go for Lambda. Typically you want consume message & dead letter queue. This is very easy to setup with Lambda.
https://github.com/RutledgePaulV/piped is an SQS client implemented with aws-api, might be worth checking out the source code
if it's not possible, I'll do something like this