0

I have to work with a code from reactive-kafka module: https://github.com/akka/reactive-kafka/blob/master/README.md

My code starts with:

val kafka = new ReactiveKafka()

val kafkaIdpsMsgs: Publisher[StringKafkaMessage] = kafka.consume(
      ConsumerProperties(
        brokerList = kafkaHosts,
        zooKeeperHost = zkHosts,
        topic = "test",
        groupId = "idps-translator",
        decoder = new StringDecoder()
      ).readFromEndOfStream())

    val kafkaSamples: Subscriber[String] = kafka.publish(ProducerProperties(
      brokerList = kafkaHosts,
      topic = "test",
      encoder = new StringEncoder()
    ))

I want to produce a message (by the publisher). What is the code I have to write to make it happen?

CrazySynthax
  • 13,662
  • 34
  • 99
  • 183
  • Are you using Akka and Akka's Reactive Streams in your project ? First read and understand Akka Reactive Streams. Only then will you be able to use ReactiveKafka. And if you do not need Akka's Reactive Streams for your project, then Reactive Kafka is not a right fit for you. – sarveshseri Aug 23 '16 at 08:55
  • I agree with @SarveshKumarSingh. Keep in mind `reactive-kafka` is `Akka Streams connector for Apache Kafka`. Are you using `akka-streams` (http://doc.akka.io/docs/akka/2.4/scala/stream/index.html)? – mfirry Aug 23 '16 at 14:30

1 Answers1

0
val done = Source(1 to 100)
  .map(_.toString)
  .map { elem =>
    new ProducerRecord[Array[Byte], String]("topic1", elem)
  }
  .runWith(Producer.plainSink(producerSettings))

you can go through this documentation : http://doc.akka.io/docs/akka-stream-kafka/current/producer.html

Kiran Sunkari
  • 301
  • 1
  • 3
  • 15