Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Does order of MqttClient's methods matters?

MQTT is inherently an event / message oriented protocol where events can occur at any point in time.  Rather than having the application block waiting for events / messages to arrive the MqttClient  provides the setCallback method where the application can provide an instance of MqttCallBack. The callback is then invoked when asynchronous events occur for instanceL-
  • A new message has arrived matching a previously setup subscription
  • When a connection has been lost
As you spotted it is important to setup the callback early to ensure that connection lost events are not missed (which could be straight after a successful connect) and that messages are not lost when they arrive straight after connect if a subscription was setup on a previous non clean session connection.

All the best


From:        Sigmund Lee <wuaner@xxxxxxxxx>
To:        paho-dev@xxxxxxxxxxx
Date:        23/09/2014 09:34
Subject:        [paho-dev] Does order of MqttClient's methods matters?
Sent by:        paho-dev-bounces@xxxxxxxxxxx

I am planing build a Push Notification service using RabbitMQ + Paho client. I noticed that method setCallback() of MqttClient must invoke before connect() & subscribe(), otherwise Non-clean-sessioned messages that publish since last connection disconnect will not be processed. Does that mean order of MqttClient's methods matters?

And any other points I must be aware when using Paho MQTT java Client?_______________________________________________
paho-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Back to the top