(String topic)
| 28 | private final Properties props = new Properties(); |
| 29 | |
| 30 | public Producer(String topic) |
| 31 | { |
| 32 | props.put("serializer.class", "kafka.serializer.StringEncoder"); |
| 33 | props.put("metadata.broker.list", "localhost:9092"); |
| 34 | // Use random partitioner. Don't need the key type. Just set it to Integer. |
| 35 | // The message is of type String. |
| 36 | producer = new kafka.javaapi.producer.Producer<Integer, String>(new ProducerConfig(props)); |
| 37 | this.topic = topic; |
| 38 | } |
| 39 | |
| 40 | public void run() { |
| 41 | int messageNo = 1; |