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

    https://github.com/apache/spark/pull/4270#discussion_r23827773
  
    --- Diff: 
external/mqtt/src/test/scala/org/apache/spark/streaming/mqtt/MQTTStreamSuite.scala
 ---
    @@ -121,8 +130,18 @@ class MQTTStreamSuite extends FunSuite with Eventually 
with BeforeAndAfter {
             val message: MqttMessage = new MqttMessage(data.getBytes("utf-8"))
             message.setQos(1)
             message.setRetained(true)
    +
    +        def tryPublish(times: Int): Unit =
    +          if (times > 0) try {
    +            msgTopic.publish(message)
    +          } catch {
    +            case e: MqttException if e.getReasonCode == 
MqttException.REASON_CODE_MAX_INFLIGHT =>
    +              Thread.sleep(50) // wait for Spark streaming to consume 
something from the message queue
    +              tryPublish(times - 1)
    +          }
    +
             for (i <- 0 to 100) {
    -          msgTopic.publish(message)
    +          tryPublish(3)
    --- End diff --
    
    for (i <- 0 to 100) {
        try {
              msgtopic.publish(message)
              println("Published data. topic: %s; Message: 
%s".format(msgtopic.getName(), message))
          } catch {
             case e: MqttException => Thread.sleep(1)
           }
    }
    I think tread sleep is 1 second  is fine.  


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