Fork me on GitHub

(required background knowledge here is how laziness works if you don’t get that)


what you guys are using to communicate with aws ? s3 / cognito / sqs … ?


was reaging that repo, but seems do not have support for aws cognito yet


We don't use Cognito here, but Amazonica is just a very thin wrapper around the official AWS java classes. If they support Cognito, then so should Amazonica


currently it seems to wrap:

iaint14:10:14, AWSCognitoIdentityProviderClient, and


seems they have support for cognito. was reading the tests and didnt find any test for cognito ( ) I will give a try


@oliv From my experience, Amazonica is very hard to debug because it does way too much magic. I have been using the Amazon Java SDK for most things. At least is well documented, you mostly have to deal with interop which in Clojure is fine and also you get decent stack traces when shit breaks


Any suggestions on material that could help me better understand core.async? I have read the Brave Clojure intro to it and saw some of the videos by Tim Baldridge on the topic but I still don't feel confident enough with it. More down to earth examples would probably help a lot.


The advice in this post helped me along:


Mostly because I was trying to use it for everything


Thanks a lot. I indeed think I might be misunderstanding its usage in a few cases. Also feel like a lot of the struggle comes from not being very familiar with RX-like stuff.


The distinction that clicked with me is core.async is for coordinating multiple async actions, not solitary events like a callback


i have an app which basically reads from kafka topic using kakfa streams and calls a rest end point. Im writing an end to end test using embedded kafka The problem is with-redef is not working here

(defn start-stream [config]
  (let [stream (KafkaStreams. (topology config) (StreamsConfig. (properties config)))]
    (.start stream)

(defn topology [config]
  (let [builder (KStreamBuilder.)]
      (.stream builder (into-array String [(.getValueAsString config "my_sample_topic")]))
      (.mapValues (value-mapper process-transaction)))

(defn value-mapper [process]
    (apply [_ v] (process v))))
(defn process-transaction [transaction]
Im trying to with-redef function process-transaction but it does not work. Is Java interop the problem here , how to solve it ?

Alex Miller (Clojure team)16:10:00

I don’t understand what you’re trying to do or what isn’t working


i’m basically trying to with-redef a clojure function which is being called from java

Alex Miller (Clojure team)16:10:03

I don’t see with-redefs anywhere?

Alex Miller (Clojure team)16:10:43

with-redefs affects dynamic scope so you would need to call it around the Java invocation (which seems challenging?)


i wrote the test with with-redef in the most outside scope but still the original function was being called

Alex Miller (Clojure team)16:10:34

you might be encountering issues with multiple threads (where with-redefs won’t work)

Alex Miller (Clojure team)16:10:35

or rather I should say, it will work, but there are timing issues that may not result in the desired effect


FYI @kevinbheda It's considered a bit rude to @ people who are not already involved in a conversation in the channel.


hey sorry , will keep this mind


thank you @rinaldi for your 2 cents ! So when you have to use aws you are interoping, right ?


I have a wrapper around SQS for instance that I use all the time @oliv. It looks something like this:

(ns fetchers.sqs
           [ DeleteMessageRequest Message ReceiveMessageRequest SendMessageBatchRequest SendMessageBatchRequestEntry SendMessageRequest]))

(defn delete-message
  [^AmazonSQSClient client queue-url message]
  (println "Deleting message from SQS...")
  (println "URL:" queue-url)
  (println "Message:" message)
  (->> message
       (DeleteMessageRequest. queue-url)
       (.deleteMessage client)))


cool, and the aws credentials ?


As you can see it's not too bad as Clojure handles interop in a very nice way


looks good @rinaldi, what about the credentials, how are you handling that ?


I use Amazon's client builders. For SQS, it looks like this:

(def ^:private sqs-client (AmazonSQSClientBuilder/defaultClient))


This will get all the information needed from either env vars (for production mostly) or from your ~/.aws


nice ! perfect !


one last question, sorry to bother you so much. how are you doing to polling the sqs and get messages from there ?


I mean, are you creating a thread ? some scheduler ?


@oliv No problem. This is what I also have on my wrapper:

(defn receive-messages
  [^AmazonSQSClient client queue-url]
  (let [request (-> (ReceiveMessageRequest. queue-url)
                    (.withMaxNumberOfMessages (Integer/valueOf queue-limit)))
        received-messages (->> (.receiveMessage client request)
    (println "Receiving messages from SQS...")
    (println "URL:" queue-url)
    (println "Number of messages received:" (count received-messages))
    (map (partial message-map queue-url) received-messages)))


I see, but someone is calling receive-messages in background ( polling interval somewhere ), right ?


Yes, I have an ad hoc polling implementation calling this function from time to time. Unfortunately the SDK doesn't provide this out of the box (as far as I know)


@oliv This could potentially help you on that part:


Is there way to get the lein config from project.clj in an arbitrary clojure process started from lein run?


For example, So I could do something like (get-in config :source-paths)


@nbardy Can't you expose it as an env var? Something like:

$ CONF=`cat project.clj` lein run my-task


Then inside your task you could do something like:

(edn/read-string (System/getenv "CONF"))


Can CIDER be configured to warn in case of a lein error? With a certain bug in my source code, lein repl tells me #error {:cause Unable to resolve symbol: Foo in this context ... }, then starts a REPL anyway with my project's namespace prompt. cider-jack-in just gives me the prompt, leaving it to me to discover that something is busted, then try to figure out what. Is there a better workflow than first running lein repl to make sure your project is qualified for cider-jack-in? Running Emacs 25.2.2, just installed CIDER from Melpa-stable. [No answer on #cider after two days, so trying here...]


What is one simple way to evaluate whether any item of a sequence is nil?


Say sequence is

[true true true false true]
, I would want result to be true (as in, at least one nil? was found).


(some? nil? seq)


I may have answered my own question.


Thanks! 🙂


OK got it.

(some false? seq)