Here is paho Async client:
client = new MqttAsyncClient(appProps.getProperty("mqtt.broker"), appProps.getProperty("mqtt.clientId"), new MemoryPersistence()); client.setCallback(this); client.connect(null, new IMqttActionListener() { @Override public void onSuccess(IMqttToken imt) { try { client.subscribe(Constants.internalTopics, Constants.internalTopicQOS); } catch (MqttException ex) { ex.printStackTrace(); } } @Override public void onFailure(IMqttToken imt, Throwable thrwbl) { thrwbl.printStackTrace(); } }); Here I am sending messages in loop:
while (iterator.hasNext()) { try { client.publish("user/" + userId + "/downstream", mqttMessage); } catch(Exception ex) { ex.printStackTrace(); } } Error:
Too many publishes in progress (32202) at org.eclipse.paho.client.mqttv3.internal.ClientState.send(ClientState.java:436) at org.eclipse.paho.client.mqttv3.internal.ClientComms.internalSend(ClientComms.java:121) at org.eclipse.paho.client.mqttv3.internal.ClientComms.sendNoWait(ClientComms.java:139) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.publish(MqttAsyncClient.java:858) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.publish(MqttAsyncClient.java:836) I am using Rabbitmq