Kafka, mail # user - kafka producer, one per web app? - 2014-06-16, 16:13
 Search Hadoop and all its subprojects:

Switch to Threaded View
Copy link to this message
kafka producer, one per web app?
In my web application, I should be creating a single instance of a producer

So in scala I should be doing something like:

object KafkaProducer {
  // props...
   val producer = new Producer[AnyRef, AnyRef](new ProducerConfig(props))

And then say in my QueueService I would do:

class QueueService {

def send(topic: String, message: Array[Byte], partition: Array[Byte]): Unit
= {
    try {
      KakfaProducer.producer.send(new KeyedMessage(topic,message,
    } catch {
      case e: Exception =>


Threading wise, is this correct?

NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB