Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3947#discussion_r22707543
  
    --- Diff: 
examples/src/main/scala/org/apache/spark/examples/streaming/MQTTWordCount.scala 
---
    @@ -42,25 +41,34 @@ object MQTTPublisher {
         StreamingExamples.setStreamingLogLevels()
     
         val Seq(brokerUrl, topic) = args.toSeq
    +    val tempDir = Utils.createTempDir()
    +    
    +    var client: MqttClient = null
     
         try {
    -      var peristance:MqttClientPersistence =new 
MqttDefaultFilePersistence("/tmp")
    +      val peristance:MqttClientPersistence = new 
MqttDefaultFilePersistence(tempDir.getAbsolutePath)
           client = new MqttClient(brokerUrl, MqttClient.generateClientId(), 
peristance)
    -    } catch {
    -      case e: MqttException => println("Exception Caught: " + e)
    -    }
     
    -    client.connect()
    +      client.connect()
    +
    +      val msgtopic: MqttTopic = client.getTopic(topic)
    +      val msgContent: String = "hello mqtt demo for spark streaming"
    +      val message: MqttMessage = new 
MqttMessage(msgContent.getBytes("utf-8"))
     
    -    val msgtopic: MqttTopic = client.getTopic(topic)
    -    val msg: String = "hello mqtt demo for spark streaming"
    +      while (true) {
    +        msgtopic.publish(message)
    +        println("Published data. topic: " + msgtopic.getName() + " 
Message: " + message)
    +      }
    +    }
    + 
    --- End diff --
    
    ```
    } catch {
        case e:
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to