Merge pull request #106 from Telecominfraproject/WIFI-13597-fix-kafka-producer-using-poll

WIFI-13857: fix: modified code to use flush() when internal queue is not loaded
This commit is contained in:
i-chvets
2024-06-19 16:51:50 -04:00
committed by GitHub

View File

@@ -107,7 +107,16 @@ namespace OpenWifi {
NewMessage.partition(0);
NewMessage.payload(Msg->Payload());
Producer.produce(NewMessage);
Producer.poll((std::chrono::milliseconds) 0);
if (Queue_.size() < 100) {
// use flush when internal queue is lightly loaded, i.e. flush after each
// message
Producer.flush();
}
else {
// use poll when internal queue is loaded to allow messages to be sent in
// batches
Producer.poll((std::chrono::milliseconds) 0);
}
}
} catch (const cppkafka::HandleException &E) {
poco_warning(Logger_,