Skip to content

Instantly share code, notes, and snippets.

@pmackles
Created November 16, 2012 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmackles/4082757 to your computer and use it in GitHub Desktop.
Save pmackles/4082757 to your computer and use it in GitHub Desktop.
import java.util.Properties;
import kafka.javaapi.producer.Producer;
import kafka.javaapi.producer.ProducerData;
import kafka.producer.ProducerConfig;
public class DCSProducer {
public static void main(String args[]) {
Properties props = new Properties();
props.put("zk.connect", "use-rabbitmq01.ec2.demdex.com:2181");
props.put("serializer.class", "kafka.serializer.StringEncoder");
props.put("producer.type", "async");
// props.put("queue.enqueueTimeout.ms", "2");
ProducerConfig config = new ProducerConfig(props);
Producer<String, String> producer = new Producer<String, String>(config);
try {
for (int i = 0; i < 200000; i++) {
ProducerData<String, String> data = new ProducerData<String, String>("aam.segments", "test-message sdflkjdj sdfljslkdjf sdflkjsdlkfjs sdfjsdlkfj sdfljsdlkfj sdfjsdlkfj sfjsdlkfjsldjf sdfjsdlfkjsdlfj sdfjsdlfkjlksdjf sdfljsdlfkjsdflj sdfjsdlfkjsdfw gedfgdfg dfdfgdfg dsdfsdf sdfsdfsdf sdfsdf sdfsdf sdfsdfsf sdfsdfdsf abcde abcde sfkldsf sdfsdf sdfsdf sdfsdf adsd asdasd asd asdasd asdasd asdasd asdasd asdasd asdasd asdasd sdfsdf sdfsdfs sdfsdf sdfsdf sdfsdf sdfsdf sfsdf sdfsdf sdf sdf sdf weerewr werwerwer werwerwer werwerwerw sf sdfsdfsdf dsf sdf sdf sdf sdf sdf s df sdfs df sdf" + i);
producer.send(data);
// System.out.println("sent " + i);
}
} finally {
System.out.println("close");
producer.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment