You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by prateek arora <pr...@gmail.com> on 2015/10/14 19:13:01 UTC

facing issue in async producer application

Hi

I want to create producer in async mode so i can send message in 5 sec
interval.

below is my code :


Map<String, Object> props = new HashMap<String, Object>();
                props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
metadataBroker);
//              props.put(ProducerConfig.ACKS_CONFIG, "0"); // don't wait
for ACKs
                props.put("producer.type", "async"); // don't wait for ACKs
                props.put("queue.buffering.max.ms", "5000"); // don't wait
for ACKs

                Serializer<String> keySerializer = new StringSerializer();
                Serializer<byte[]> valueSerializer = new
ByteArraySerializer();
                producer = new KafkaProducer<String, byte[]>(props,
keySerializer, valueSerializer);
 ProducerRecord<String, byte[]> imageRecord;
imageRecord = new ProducerRecord<String, byte[]>(topicName,
recordKey,imageBytes);
producer.send(imageRecord);