Open Donadominic opened 1 year ago
The MQTT spec does not preserve message ordering. You need to add a serial number to your body if you want to preserve ordering in the client side logic.
Actually, on further reading, 3.1.1 should be ordered but perhaps Paho does not implement this.
https://groups.google.com/g/mqtt/c/UfcO0HtLq9s
Anyway, I would add a serial number to the payload to identify out of order messages on the client and logic to buffer messages if ordering is important to your business logic.
While using NanoMQ when the client is disconnected and connected back again the order in which the messages are published is not preserved. It is reading data in some random order. But when the client is connected the messages are received in proper order. How to receive messages in proper order?
I was sending a sequence of messages when the client was disconnected. And when the client is connected back again I am expecting the messages to be received in the proper order they are send.
Publisher Code public class Publisher { public static void main(String[] args) {
} }
Consumer Code public class Subscriber3 { public static void main(String[]args) throws MqttException { MqttClient client =new MqttClient("tcp://192.168.2.8:1885","subscriber004",new MemoryPersistence()); MqttConnectOptions options=new MqttConnectOptions(); options.setCleanSession(false); options.setUserName("user009"); options.setPassword("password008".toCharArray()); client.connect(options);
} }
But messages are received in some random order. All the messages are received. But I need them in the order they are published.
NanoMQ latest version Java Client in Windows and NanoMq on ubuntu centos in docker container Java- Eclipse Paho Publishing a sequence of messages when the client is disconnected and when client is connected back need persisted messages in order
I need messages in the order in which they are published not in some random order.