의존성
[org.apache.kafka/kafka-clients "2.5.0"]
사용코드
(ns kafka-demo2.core
(:import [org.apache.kafka.common.serialization StringSerializer]
[org.apache.kafka.clients.producer KafkaProducer ProducerRecord])
(:gen-class))
(def config
{"bootstrap.servers" "127.0.0.1:9092"
"key.serializer" StringSerializer
"value.serializer" StringSerializer})
(defn publish [topic str]
(let [producer (KafkaProducer. config)
record (ProducerRecord. topic str)]
(try
(.send producer record)
(finally (.close producer)))))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "push A")
(publish "yhnam-topic" "A"))
도커
https://github.com/ssisksl77/clojure-breadcrumb
위 깃허브 참고
실행
별거 없음 위 깃허브 참고
$ docker-compose up
$ lein uberjar
$ java -jar kafka-demo2-0.1.0-standalone.jar
그외 정리
https://www.notion.so/tombox/db6bc836f25d41948d28f3aff9ec1aff
댓글 없음:
댓글 쓰기