CrossClj

0.1.0 docs

SourceDocs



RECENT

    kafkian

    Clojars

    Jun 17, 2016


    OWNER
    Dayo Oliyide
    dayooliyide.com

    Readme

    Index of all namespaces


    « Project + dependencies

    A Clojure wrapper for Kafkas 0.9.x client

    kafkian.consumerDocsSource
    Clojure interface for Kafka Consumer API. For
    complete JavaDocs, see:
    http://kafka.apache.org/090/javadoc/index.html?org/apache/kafka/clients/consumer/package-summary.html
    kafkian.producerDocsSource
    Clojure interface for Kafka Producer API. For
    complete JavaDocs, see:
    http://kafka.apache.org/090/javadoc/index.html?org/apache/kafka/clients/producer/package-summary.html
    The README below is fetched from the published project artifact. Some relative links may be broken.

    kafkian

    A Clojure library for the Kafka 0.9 release.

    This library takes it’s inspiration and some code from the clj- kafka library.

    It’s raison d’être is that I had an immediate need for a clojure wrapper/interface to Kafka 0.9, which clj-kafka doesn’t currently have.

    NOTE:This library is NOT compatible with Kafka Clusters below version 0.9 Use the clj- kafka for Kafka Clusters version 0.8 So far it’s only been tested against 0.9 Kafka Clusters

    Installation

    Add the following to your Leiningen project.clj:

    latest kafkian version

    Usage

    Producer

    (require '[kafkian.producer :as kp])
    
    (with-open [p (kp/producer {"bootstrap.servers" "localhost:9092"}
                               (kp/string-serializer)
                               (kp/string-serializer))]
      @(kp/send p (kp/record "topic-a" "Hola Mundo!")))
    

    Consumer

    (require '[kafkian.consumer :as kc])
    
    (with-open [c (kc/consumer {"bootstrap.servers" "localhost:9092"
                                "group.id" "consumer-id"}
                                (kc/string-deserializer)
                                (kc/string-deserializer))]
      (kc/subscribe c "topic-a")
      (kc/messages c))
    

    Admin

    (require '[kafkian.admin :as ka])
    
    (def zk-util (ka/zk-utils "localhost:2181"))
    
    (ka/create-topic zk-util "events")
    
    (ka/create-topic zk-util "events2" :partition 3 :replication-factor 3)
    
    (ka/create-topic zk-util "events-store" :topic-conifg {"cleanup.policy" "compact"})
    
    (ka/topic-exists? zk-util "events")
    
    (ka/delete-topic zk-util "events2")
    

    License

    Copyright © 2016

    Distributed under the Apache License v 2.0 (http://www.apache.org/licenses/LICENSE-2.0)