Mqtt qos = 3 appreciated actual examples

Jane Books Address: https://www.jianshu.com/p/8b0291e8ee02

 

 qos = 2 Example illustrates

   = Example: to release the App Topic gateway acquires the next gateway stored in the gateway device:
Step a: Publisher (the App), App storage msg-> publish-> 
 Broker (server), the server stores msg
 server replies app PUBREC, distributing the received published
 app tells the server PUBREL, publishing release
 server replies App, PUBCOMP, then App callBack callback in
 @Override
   public void deliveryComplete (IMqttDeliveryToken token) {
    the try {
        // message sent successfully callback
        LogUtils.d (TAG, "mqtt message delivery success: "+ new new String (token.getMessage () getPayload ().));
      } the catch (MqttException E) {
        e.printStackTrace ();
       }
  }
 the App change in Mqtt callback method callback message indicating successful transmission, the server receives 100%
 App and the Delete (Msg)
    - the end result: a message transmitted to the server 100%
   
  two steps:  *** the gateway server sends data to the subscriber of a topic
   *** Publisher (server) -> Storage msg-> push-to-gateway (Subscriber),
   gateway storage store (msg),
   the gateway server reply PUBREL, received a publishing
   service reply Gateway, released released
   gateway server reply PUBCOMP
   server delete (msg )

   - The end result: the gateway receives the data 100%

  Step Three:   After *** gateway receives msg, query data gateway under the list
    then the time Publisher (that is, the gateway) Subscriber (App), App subscribed to receive data Topic
    Publisher (gateway) to the server sends publish Broker,
    Broker reply gateway PUBREC
    gateway server pubrel reply
    service gateway pubcomp reply
    gateway delete data

    - The end result: the gateway to the server data 100%

   Step Four: *** app subscription server transmits data of a particular topic
        // return all messages where
    @Override
    public void messageArrived (String topic, MqttMessage Message) throws Exception {
       // the App accept all messages handled here
    }
    - - the end result: a server data push App 100% Topic subscribed to change the

Published 141 original articles · won praise 51 · views 90000 +

Guess you like

Origin blog.csdn.net/dreams_deng/article/details/89480309