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


##########
extensions/mqtt/processors/PublishMQTT.cpp:
##########
@@ -34,76 +34,229 @@ void PublishMQTT::initialize() {
   setSupportedRelationships(relationships());
 }
 
-void PublishMQTT::onSchedule(const std::shared_ptr<core::ProcessContext> 
&context, const std::shared_ptr<core::ProcessSessionFactory> &factory) {
+void PublishMQTT::readProperties(const std::shared_ptr<core::ProcessContext>& 
context) {
+  if (!context->getProperty(Topic).has_value()) {
+    logger_->log_error("PublishMQTT: could not get Topic");
+  }
+
   if (const auto retain_opt = context->getProperty<bool>(Retain)) {
     retain_ = *retain_opt;
   }
   logger_->log_debug("PublishMQTT: Retain [%d]", retain_);
 
-  AbstractMQTTProcessor::onSchedule(context, factory);
+  if (const auto message_expiry_interval = 
context->getProperty<core::TimePeriodValue>(MessageExpiryInterval)) {
+    message_expiry_interval_ = 
std::chrono::duration_cast<std::chrono::seconds>(message_expiry_interval->getMilliseconds());
+    logger_->log_debug("PublishMQTT: MessageExpiryInterval [%" PRId64 "] s", 
int64_t{message_expiry_interval_->count()});
+  }
+
+  in_flight_message_counter_.setMqttVersion(mqtt_version_);
+  in_flight_message_counter_.setQoS(qos_);
 }
 
-void PublishMQTT::onTrigger(const std::shared_ptr<core::ProcessContext>& 
/*context*/, const std::shared_ptr<core::ProcessSession> &session) {
-  // reconnect if needed
-  reconnect();
+void PublishMQTT::onTriggerImpl(const std::shared_ptr<core::ProcessContext>& 
context, const std::shared_ptr<core::ProcessSession> &session) {
+  std::shared_ptr<core::FlowFile> flow_file = session->get();
 
-  if (!MQTTAsync_isConnected(client_)) {
-    logger_->log_error("Could not publish to MQTT broker because disconnected 
to %s", uri_);
-    yield();
+  if (!flow_file) {
     return;

Review Comment:
   Good point! Added.



-- 
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