需要传递多个数据(对象)和文件数据,
是否有任何序列化程序可用于传递对象或任何方式?
这是传递文件数据的代码,
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()));
暂无答案!
目前还没有任何答案,快来回答吧!