Open peijl1998 opened 5 years ago
It's not possible at the moment and I'm not sure it's a good idea to expose the internal buffer to the application. Also the messages are serialized so you would have to deserialize them if you need to print/access anything inside them. Perhaps some iterator could be provided to the internal queue. Maybe @mfontanini can comment.
As @accelerated, it's not a good idea to start exposing internals. Also, you can implement your logic yourself: accumulate whatever data you have, when you call flush export it or do whatever you need and then clear your current stats.
Now I use buffered producer and add_message to write data to kafka. But before flushing, I want to measure something on each data from producer's buffer. So, how can I read each message from producer's buffer?
My code is like this: ` BufferedProducer producer(config);
producer.add_message(MessageBuilder( kafka_topic ).payload(mydata));
if (producer.get_buffer_size() > buffer_threshold) { // get each data from producer's buffer <----- HERE! producer.flush(); } `
Thanks! :)