jackdaw

https://github.com/FundingCircle/jackdaw
dangercoder 2019-06-03T14:42:24.000800Z

Are there any guides on how to create a consumer? I currently get Missing required configuration "key.deserializer" which has no default value.

dharrigan 2019-06-03T14:47:13.001600Z

Sure

dharrigan 2019-06-03T14:47:20.001800Z

Here's a snippet:

dharrigan 2019-06-03T14:48:05.002100Z

(defn -main
  [& _]
  (echo-environment)
  (with-open [consumer (-> (jackdaw-client/consumer consumer-config)
                           (jackdaw-client/subscribe [my-topic]))]
    (doseq [message (jackdaw-log/log consumer (-> env :topic :poll-interval-ms))]
      (process/foreach message))))

dharrigan 2019-06-03T14:48:15.002300Z

(def consumer-config
  (merge (-> env :broker)
         {"key.deserializer" (.getName StringDeserializer)
          "value.deserializer" (.getName StringDeserializer)}))

dharrigan 2019-06-03T14:48:55.002700Z

(:require [my-foo-process :as process]
            [jackdaw.client.log :as jackdaw-log]
            [jackdaw.client :as jackdaw-client]
            [jackdaw.serdes.json :as json-serde]
            [config.core :refer [env]]
            [clojure.pprint :refer [pprint]])
  (:import [org.apache.kafka.common.serialization Serdes StringDeserializer])
  (:gen-class))

dharrigan 2019-06-03T14:49:36.003400Z

I use config.core to store in a config.edn values, such as :topic, :poll-interval-ms and :broker

dharrigan 2019-06-03T14:49:56.003700Z

hope that helps to get you on the path

dangercoder 2019-06-03T14:51:07.005100Z

Ah yeah, thanks for the example. ✌️

dharrigan 2019-06-03T14:52:22.005800Z

it's s bit, bitty, since it's copy&pasta from a program in use, so can't show company stuff

dharrigan 2019-06-03T14:52:28.006200Z

but it's a generic enough setup

dangercoder 2019-06-03T14:52:47.006600Z

Still not 100% about when to use value-serdes and key-serdes in the client.consumer api though 😄

dangercoder 2019-06-03T14:53:17.007200Z

I know the java api for kafka, just something I dont want to use 🙂

dangercoder 2019-06-03T14:58:17.007600Z

nvm I figured it out now

dangercoder 2019-06-03T14:58:56.008200Z

Do you process your messages "async" with core.async @dharrigan?

dharrigan 2019-06-03T14:59:31.008400Z

nope

dharrigan 2019-06-03T14:59:47.008700Z

no need to complicate things for now, works fine 😉