0

Need to pass multiple data(object) along with file data,

Is there any serializer available to pass object or any ways?

Here is the code that just pass file data,

props.put("bootstrap.servers", "localhost:9092");
        props.put("metadata.broker.list", "localhost:9093");

        props.put("producer.type", "async");
        props.put("batch.size", "500");
        props.put("compression.codec", "1");
        props.put("compression.topic", "WRA");
        // props.put("key.serializer",
        // "org.apache.kafka.common.serialization.StringSerializer");
        props.put("key.serializer", "org.apache.kafka.common.serialization.IntegerSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");

        org.apache.kafka.clients.producer.Producer<Integer, byte[]> producer = new KafkaProducer<Integer, byte[]>(
                props);

        producer.send(new ProducerRecord<Integer, byte[]>("topic1", file.getBytes()));
Vimal Dhaduk
  • 994
  • 2
  • 18
  • 43
  • Checkout this answer :http://stackoverflow.com/questions/39112201/is-it-possible-to-transfer-files-using-kafka/39129352#39129352 , It tells about how to use MapSerializer with kafka. – Rambler Oct 20 '16 at 10:21
  • @Rambler, Need to pass data along with file. Not only data – Vimal Dhaduk Oct 20 '16 at 11:28
  • 1
    See http://stackoverflow.com/a/40158971/2229409 answer, you can implement your own value serializer for an object including metadata and your file. – Luciano Afranllie Oct 20 '16 at 15:57

0 Answers0