Hi,
I use kafka 0.8. When I run the kafka console producer using
./kafka-console-producer.sh --topic test.compress.e --compress true
--broker-list 127.0.0.1:9092
Iam able to see compressed messages in the log.
But when I run a Java producer class using the following properties, no
message is getting into the data log for that topic.
Please tell me what do I need to get the compressed message into log using
java producer
This the code snippet:
Properties props = *new* Properties();
props.put("broker.list", "127.0.0.1:9092");
props.put("serializer.class", "kafka.serializer.StringEncoder");
props.put("compress", "true");
props.put("compression.codec", "gzip");
props.put("compressed.topics", "test.compress22");
ProducerConfig config = *new* ProducerConfig(props);
Producer<String, String> producer = *new* Producer<String, String>(config);
String KafkaTopic = "test.compress22";
String strLine;
*try* {
*for*(*int* i=1;i<=2; i++){
strLine="Message "+I;
KeyedMessage<String, String> s = *new* KeyedMessage<String,
String>(KafkaTopic, *null*, strLine);
producer.send(s);
producer.close();
} *catch* (Exception e) {
e.printStackTrace();
Thanks
Arathi
I use kafka 0.8. When I run the kafka console producer using
./kafka-console-producer.sh --topic test.compress.e --compress true
--broker-list 127.0.0.1:9092
Iam able to see compressed messages in the log.
But when I run a Java producer class using the following properties, no
message is getting into the data log for that topic.
Please tell me what do I need to get the compressed message into log using
java producer
This the code snippet:
Properties props = *new* Properties();
props.put("broker.list", "127.0.0.1:9092");
props.put("serializer.class", "kafka.serializer.StringEncoder");
props.put("compress", "true");
props.put("compression.codec", "gzip");
props.put("compressed.topics", "test.compress22");
ProducerConfig config = *new* ProducerConfig(props);
Producer<String, String> producer = *new* Producer<String, String>(config);
String KafkaTopic = "test.compress22";
String strLine;
*try* {
*for*(*int* i=1;i<=2; i++){
strLine="Message "+I;
KeyedMessage<String, String> s = *new* KeyedMessage<String,
String>(KafkaTopic, *null*, strLine);
producer.send(s);
producer.close();
} *catch* (Exception e) {
e.printStackTrace();
Thanks
Arathi