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

    https://github.com/apache/spark/pull/4178#discussion_r24432610
  
    --- Diff: 
examples/src/main/scala/org/apache/spark/examples/streaming/MQTTWordCount.scala 
---
    @@ -42,25 +40,33 @@ object MQTTPublisher {
         StreamingExamples.setStreamingLogLevels()
     
         val Seq(brokerUrl, topic) = args.toSeq
    +    
    +    var client: MqttClient = null
     
         try {
    -      var peristance:MqttClientPersistence =new 
MqttDefaultFilePersistence("/tmp")
    -      client = new MqttClient(brokerUrl, MqttClient.generateClientId(), 
peristance)
    +      val persistence = new MemoryPersistence()
    +      client = new MqttClient(brokerUrl, MqttClient.generateClientId(), 
persistence)
    +
    +      client.connect()
    +
    +      val msgtopic  = client.getTopic(topic)
    +      val msgContent = "hello mqtt demo for spark streaming"
    +      val message = new MqttMessage(msgContent.getBytes("utf-8"))
    +
    +      while (true) {
    +        try {
    +          msgtopic.publish(message)
    +          println("Published data. topic: %s; Message: 
%s".format(msgtopic.getName(), message))
    +        } catch {
    +          case e: MqttException if e.getReasonCode == 
MqttException.REASON_CODE_MAX_INFLIGHT =>
    --- End diff --
    
    OK, at least log a warning. Or else this could silently spin forever as 
long as the queue is full. Yes it's an example but still seems funny.
    
    Also, really minor but the `org.apache.spark.streaming.StreamingContext` 
import you moved in `MQTTUtils` is now out of order. 


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to