Skip to content

Commit

Permalink
fix: modified kafka manager to use poll in producer
Browse files Browse the repository at this point in the history
https://telecominfraproject.atlassian.net/browse/WIFI-13597

NOTE: This fix is port of Telecominfraproject/wlan-cloud-ucentralgw#360

Summary of changes:
- Modified code in KafkaManager to use poll instead of flush for every
  messages sent. flush is used only on empty internal notification queue
  in idle times.

Signed-off-by: Ivan Chvets <[email protected]>
  • Loading branch information
i-chvets committed Jun 13, 2024
1 parent 20785d8 commit 3b8a8ba
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/framework/KafkaManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace OpenWifi {
NewMessage.partition(0);
NewMessage.payload(Msg->Payload());
Producer.produce(NewMessage);
Producer.flush();
Producer.poll((std::chrono::milliseconds) 0);
}
} catch (const cppkafka::HandleException &E) {
poco_warning(Logger_,
Expand All @@ -117,6 +117,10 @@ namespace OpenWifi {
} catch (...) {
poco_error(Logger_, "std::exception");
}
if (Queue_.size() == 0) {
// message queue is empty, flush all previously sent messages
Producer.flush();
}
Note = Queue_.waitDequeueNotification();
}
poco_information(Logger_, "Stopped...");
Expand Down

0 comments on commit 3b8a8ba

Please sign in to comment.