Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
92 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: '3' | ||
services: | ||
zookeeper: | ||
image: wurstmeister/zookeeper | ||
ports: | ||
- "2181" | ||
hostname: zookeeper | ||
kafka: | ||
image: wurstmeister/kafka | ||
command: [start-kafka.sh] | ||
ports: | ||
- "9092" | ||
hostname: kafka | ||
environment: | ||
KAFKA_ADVERTISED_HOST_NAME: kafka # docker-machine ip | ||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 | ||
KAFKA_ADVERTISED_PORT: 9092 | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
depends_on: | ||
- "zookeeper" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import com.typesafe.config.ConfigFactory | ||
import monix.eval.Task | ||
import monix.reactive.{Consumer, Observable} | ||
import org.apache.kafka.clients.consumer.ConsumerRecord | ||
|
||
class Example { | ||
|
||
val config = ConfigFactory.load() | ||
|
||
// write data to kafka (assumes a configuration akin to kafka4m.producer.topic = someNewTopic) | ||
val kafkaWriter: Consumer[(String, Array[Byte]), Long] = kafka4m.writeKeyAndBytes(config) | ||
|
||
// read data from kafka (assumes a configuration akin to kafka4m.consumer.topic = originalTopic) | ||
val kafkaData: Observable[ConsumerRecord[String, Array[Byte]]] = kafka4m.read(config) | ||
|
||
// then we'd write it back into kafka like this. | ||
val task: Task[Long] = kafkaData.map(r => (r.key, r.value)).consumeWith(kafkaWriter) | ||
|
||
} |