szaszm commented on code in PR #1432:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1432#discussion_r1082400747


##########
extensions/mqtt/processors/PublishMQTT.h:
##########
@@ -62,72 +68,116 @@ class PublishMQTT : public 
processors::AbstractMQTTProcessor {
 
   ADD_COMMON_VIRTUAL_FUNCTIONS_FOR_PROCESSORS
 
-  class ReadCallback {
+  void readProperties(const std::shared_ptr<core::ProcessContext>& context) 
override;
+  void onTriggerImpl(const std::shared_ptr<core::ProcessContext>& context, 
const std::shared_ptr<core::ProcessSession>& session) override;
+  void initialize() override;
+
+ private:
+  /**
+   * Counts unacknowledged QoS 1 and QoS 2 messages to respect broker's 
Receive Maximum
+   */
+  class InFlightMessageCounter {
    public:
-    ReadCallback(PublishMQTT* processor, uint64_t flow_size, uint64_t 
max_seg_size, std::string topic, MQTTAsync client, int qos, bool retain)
-        : processor_(processor),
-          flow_size_(flow_size),
-          max_seg_size_(max_seg_size),
-          topic_(std::move(topic)),
-          client_(client),
-          qos_(qos),
-          retain_(retain) {
+    void setMqttVersion(const MqttVersions mqtt_version) {
+      mqtt_version_ = mqtt_version;
+    }
+
+    void setQoS(const MqttQoS qos) {
+      qos_ = qos;
+    }
+
+    void setMax(const uint16_t new_limit) {
+      limit_ = new_limit;
     }
 
-    int64_t operator()(const std::shared_ptr<io::InputStream>& stream);
+    // increase on sending, wait if limit is reached
+    void increase();

Review Comment:
   I'm not sure whether this failure scenario is possible. I'd set it to a 
shorter period (maybe 5 sec?), and let the processor yield if it can't acquire 
the semaphore. It could try again on the next trigger.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to