Created
September 29, 2014 09:13
-
-
Save garyrussell/80577e9e8eb865aa37f0 to your computer and use it in GitHub Desktop.
Exhibit Deadlock in Paho Java Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.springframework.integration.mqtt; | |
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; | |
import org.eclipse.paho.client.mqttv3.MqttCallback; | |
import org.eclipse.paho.client.mqttv3.MqttClient; | |
import org.eclipse.paho.client.mqttv3.MqttMessage; | |
/** | |
* @author Gary Russell | |
* | |
*/ | |
public class Deadlock implements MqttCallback { | |
private final MqttClient mqttClient1; | |
private final MqttClient mqttClient2; | |
public static void main(String[] args) throws Exception { | |
new Deadlock().test(); | |
} | |
private Deadlock() throws Exception { | |
mqttClient1 = new MqttClient("tcp://iot.eclipse.org:1883", "foo"); | |
mqttClient1.setCallback(this); | |
mqttClient1.connect(); | |
mqttClient2 = new MqttClient("tcp://iot.eclipse.org:1883", "bar"); | |
mqttClient2.setCallback(this); | |
mqttClient2.connect(); | |
mqttClient2.subscribe("bar"); | |
} | |
private void test() throws Exception { | |
for (int i = 0; i < 16; i++) { | |
System.out.println("sending"); | |
mqttClient1.publish("bar", new MqttMessage("foo".getBytes())); | |
} | |
} | |
@Override | |
public void connectionLost(Throwable cause) { | |
} | |
@Override | |
public void messageArrived(String topic, MqttMessage message) throws Exception { | |
System.out.println(new String(message.getPayload())); | |
Thread.sleep(5000); | |
throw new RuntimeException("deadlock"); | |
} | |
@Override | |
public void deliveryComplete(IMqttDeliveryToken token) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi garyrussell ,
I am facing the same issue as referenced on
http://stackoverflow.com/questions/25620196/spring-integration-mqtt-subscriber-paho-stops-processing-messages
On my application i am pushing continious huge load I found that, sometimes application is dropping connection with IMA (mqtt) and this was happened three times in a span of 1 Lac record.
But it regains the connectivity and started consuming messages received there after.
There is some other issue which I faced during this testing.
When there is continuous load on application , at some point application stops receiving messages and we can see one message flashed on screen i.e.
May 04, 2015 2:45:29 PM org.eclipse.paho.client.mqttv3.internal.ClientState checkForActivity
SEVERE: HUGHJACK:gvjIpONtSpP: Timed out as no activity, keepAlive=60,000 lastOutboundActivity=1,430,730,869,017 lastInboundActivity=1,430,730,929,151
After this we can see that there are no messages received on application even if continuous load is pushed through utility.
This behavior I found it three times.
There is no consistent point or figures where application actually stops receiving messages.
So is this problem solved in the next releases, i am using 4.0.4 version. Please let me know .