# run main
clj -X:run
# rebel readline shell
clj -A:rebel
Created
May 3, 2022 19:35
-
-
Save thalesmg/56f0828dcdfe7684b498bf4284c31dab to your computer and use it in GitHub Desktop.
example pulsar client using basic auth in clojure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pulsar-test.core | |
(:import (org.apache.pulsar.client.api PulsarClient))) | |
(defn make-consumer | |
[] | |
(let [props (doto (java.util.Properties.) | |
(.putAll {"userId" "super" | |
"password" "superpass"})) | |
client (-> (PulsarClient/builder) | |
(.serviceUrl "pulsar://localhost:6650") | |
(.authentication | |
"org.apache.pulsar.client.impl.auth.AuthenticationBasic" | |
props) | |
(.build)) | |
consumer (-> (.newConsumer client) | |
(.topics ["my-topic"]) | |
(.subscriptionName "my-sub") | |
(.subscribe))] | |
consumer)) | |
(defn -main | |
[& _args] | |
(let [consumer (make-consumer) | |
message (.receive consumer)] | |
(println (String. (.getData message))) | |
(System/exit 0))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:deps {org.apache.pulsar/pulsar-client {:mvn/version "2.10.0"}} | |
:aliases {:rebel {:extra-deps {com.bhauman/rebel-readline {:mvn/version "0.1.4"}} | |
:main-opts ["-m" "rebel-readline.main"]} | |
:run {:exec-fn pulsar-test.core/-main}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment