Skip to content

Instantly share code, notes, and snippets.

@adekunleba
Last active October 16, 2018 16:45
Show Gist options
  • Select an option

  • Save adekunleba/1697e1ad1db389e6d0318217f3866044 to your computer and use it in GitHub Desktop.

Select an option

Save adekunleba/1697e1ad1db389e6d0318217f3866044 to your computer and use it in GitHub Desktop.
Configure Producer to connect to Confluence
import org.apache.kafka.clients.producer.KafkaProducer
import org.apache.kafka.streams.{StreamBuilder, StreamsConfig}
import java.util.Properties
val config: Properties = {
val p = new Properties()
p.put(StreamsConfig.APPLICATION_ID_CONFIG, "simple-confluent-stream")
p.put(StreamsConfig.CLIENT_ID_CONFIG, "simple-confluent-stream-client")
p.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092")
p.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer")
p.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer")
p
}
//You can make use of the config in creating a stream as shown
val streams = new KafkaProducer[String, String](config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment