https://github.com/fusesource/mqtt-client
i have an android application starting a background service where i have initiated an mqtt connection towards an apollo broker. when startService is called im initiating the MQTT from the onStartCommand setting hostname, port username, password etc.. followed by
connection = mqtt.callbackConnection();
the connect is successfull and i can clearly see that i have a consumer on my topic "uniqueId".
But when i send messages to my topic , the listener never calles the onPublish.. Another strange occurence is that if i loose my connection towards the broker , e.g i shut down the broker so that the active connection is broken, when the mqtt-client reconnects, it seems that it calles the listener and also the onPublish because then all the messages that i have stacked on my durable subscriber topic is delivered.. am i missing anything here regarding the listener?
isnt it suppose to actively consume the topic due to connection.subscribe??
Topic[] topics = { new Topic("uniqueId", QoS.AT_LEAST_ONCE) };
connection.subscribe(topics, new Callback<byte[]>() {
public void onSuccess(byte[] qoses) {
}
public void onFailure(Throwable value) {
value.printStackTrace();
}
});
connection.listener(new Listener() {
@Override
public void onConnected() {
}
@Override
public void onDisconnected() {
}
@Override
public void onFailure(Throwable value) {
}
@Override
public void onPublish(UTF8Buffer topic, Buffer payload, Runnable ack) {
ack.run();
}
});