If you're using WSL (Windows Subsystem for Linux), install the prerequisites in your WSL environment:
# Update package list
sudo apt update
# Install Java
sudo apt install openjdk-11-jdk
# Install Leiningen
curl -O https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
chmod +x lein
sudo mv lein /usr/local/bin/
lein --version
# Install Kafka (optional, for testing)
wget https://downloads.apache.org/kafka/2.8.1/kafka_2.13-2.8.1.tgz
tar -xzf kafka_2.13-2.8.1.tgz
# Install Java
brew install openjdk@11
# Install Leiningen
brew install leiningen
# Install Kafka (optional)
brew install kafka
# Install Java
sudo apt install openjdk-11-jdk # Ubuntu/Debian
# or
sudo yum install java-11-openjdk # CentOS/RHEL
# Install Leiningen
curl -O https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
chmod +x lein
sudo mv lein /usr/local/bin/
# Install Kafka
# Download from https://kafka.apache.org/downloads
Clone and setup
cd /path/to/kafka-metamorphosis
lein deps # Download dependencies
Run tests
lein test
Start REPL
lein repl
Build JAR
lein uberjar
To test the library with a real Kafka instance:
Start Zookeeper
bin/zookeeper-server-start.sh config/zookeeper.properties
Start Kafka
bin/kafka-server-start.sh config/server.properties
Create test topic
bin/kafka-topics.sh --create --topic metamorphosis-topic --bootstrap-server localhost:9092
Run examples
(require '[kafka-metamorphosis.examples :as examples])
(examples/run-examples)
;; Start REPL and load the library
(require '[kafka-metamorphosis.producer :as producer])
(require '[kafka-metamorphosis.consumer :as consumer])
;; Create a producer (requires running Kafka)
(def p (producer/create {:bootstrap-servers "localhost:9092"
:key-serializer "org.apache.kafka.common.serialization.StringSerializer"
:value-serializer "org.apache.kafka.common.serialization.StringSerializer"}))
;; Send a test message
(producer/send! p "test-topic" "key1" "Hello from REPL!")
;; Close producer
(producer/close! p)
src/kafka_metamorphosis/
├── core.clj # Main namespace and exports
├── producer.clj # Producer functions
├── consumer.clj # Consumer functions
├── util.clj # Utility functions
└── examples.clj # Usage examples
test/kafka_metamorphosis/
├── core_test.clj # Core tests
└── producer_test.clj # Producer tests
The basic wrapper is now implemented with:
Future enhancements:
Can you improve this documentation? These fine people already did:
Caio Clavico & Caio HenriqueEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |