Reputation: 227
I am using paho-mqtt to receive data from emqx broker but I am losing data because sometimes my paho-mqtt subscriber goes down. Any method to get data when I will run subscriber again it will give all published data.
Upvotes: 0
Views: 514
Reputation: 1
I hope you get a solution. I don't know your client , but paho-mqtt java client can reconnect automatically. This reconnect can be check in "connectComplete(boolean reconnect, String s)" boolean parameter
public class MqttautoClient implements MqttCallbackExtended {
.
.
.
@Override
public void connectComplete(boolean reconnect, String s) {
Log.d(TAG, "Connection connectComplete");
}
@Override
public void connectionLost(Throwable throwable) {
Log.d(TAG, "Connection lost");
}
@Override
public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception
{
Log.d(TAG, "messageArrived");
}
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
Log.d(TAG, "deliveryComplete ");
}
}
Upvotes: 0
Reputation: 263
If there is no subscriber, EMQ x will discard the message, which is a normal design.
You can try EMQ x enterprise and use backend for offline data storage.
https://docs.emqx.io/tutorial/latest/en/backend/whats_backend.html
Upvotes: 0