title: QoS1 vs QoS2 messages - difference in handling it with Paho MQTT client in Java
body: <p>In reference to <a href="http://www.hivemq.com/mqtt-essentials-part-6-mqtt-quality-of-service-levels/" rel="nofollow" title="this article">this article</a> I think I know the difference between QoS1 and QoS2 messages, but I don't know the difference in handling both of them as a Paho MQTT client.</p>
  
  <p>Imagine I subscribe to the topic like this:</p>
  
  <pre><code>MqttClient subscriber = new MqttClient(SERVER_URI, SUBSCRIBER_ID);
  subscriber.subscribe(TOPIC);
  </code></pre>
  
  <p>And then I'm publishing messages like this:</p>
  
  <pre><code>publisher.publish(TOPIC, PAYLOAD, 1, false);
  </code></pre>
  
  <p>At this moment I'm using MqttCallback interface to handle messages that arrives to subscribers. </p>
  
  <p>There is a method to override:</p>
  
  <pre><code>public void messageArrived(String topic, MqttMessage mqttMessage) {
      if(mqttMessage.isDuplicate()) {
          // is it really the duplicate message from my perspective?
      } else {...}
  }
  </code></pre>
  
  <p>In the MqttMessage we can find a isDuplicate() method, but how can I be sure that the mqttMessage that returns true is not the first message that my subscriber received?</p>
  
  <p>I am very interested in finding a solution that shows how to handle QoS1, but every answer which will clarify anything here will be appreciated.</p>
  
  <p>Best regards from Cracow!</p>