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

    https://github.com/apache/spark/pull/4270#discussion_r23828884
  
    --- 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 --
    
    I think waitForReceiverToStart() method is sufficient. Once the receiver is 
started, since the qos is set to 1 , as soon as the receiver receives the 
message, message will be flushed out from queue. If still problem exists the 
Thread.Sleep in the catch can solve the problem.


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