Kafka, mail # user - Kafka 0.8 producer within Play Framework? - 2013-02-02, 00:33
Solr & Elasticsearch trainings in New York & San Francisco [more info][hide]
 Search Hadoop and all its subprojects:

Switch to Plain View
Copy link to this message
Kafka 0.8 producer within Play Framework?
Is it possible to have a Kafka 0.8 producer inside a Play Framework
controller?  (I am new to both Kafka and Play.)

I have managed to get Java code cribbed from the Kafka examples
(below) to compile and execute within Play, but constructing the
ProducerConfig object never returns.  I am not finding anything in any
Play log.

I've also tried this using the Scala console producer as a model and
had the same result

The Kafka console producer and consumer samples are working for me.


package controllers;

import java.util.Properties;

import kafka.producer.ProducerConfig;
import kafka.javaapi.producer.Producer;
import kafka.producer.KeyedMessage;

public class Hello
   public static void hello( String v )
      Properties props = new Properties();
      props.put("zk.connect", "");
      props.put("serializer.class", "kafka.serializer.StringEncoder");
      props.put("broker.list", "localhost:9092" );

      play.Logger.info("create config");
      ProducerConfig config = new ProducerConfig(props);

      play.Logger.info("create producer");
      Producer<Integer, String> producer = new Producer<Integer,


      KeyedMessage msg = new KeyedMessage<Integer,
String>("test-topic", "Greetings!");

      producer.send( msg );

charlie w 2013-02-05, 00:13
S Ahmed 2013-02-05, 14:38
charlie w 2013-02-05, 15:14
Felix GV 2013-02-05, 18:25
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