INTEXT-89 Fix Inbound Stop When No Server

The reconnection task was not canceled in doStop().
This commit is contained in:
Gary Russell
2013-10-02 13:44:52 -04:00
parent 9fe0d02ef8
commit 76c65ec6db
2 changed files with 19 additions and 7 deletions

View File

@@ -14,7 +14,7 @@ apply plugin: 'idea'
group = 'org.springframework.integration'
repositories {
maven { url 'http://repo.springsource.org/milestone' }
maven { url 'http://repo.springsource.org/snapshot' }
maven { url 'http://repo.springsource.org/plugins-release' }
}
@@ -26,7 +26,7 @@ ext {
log4jVersion = '1.2.17'
mockitoVersion = '1.9.5'
springVersion = '3.1.3.RELEASE'
springIntegrationVersion = '3.0.0.M2'
springIntegrationVersion = '3.0.0.BUILD-SNAPSHOT'
idPrefix = 'mqtt'

View File

@@ -22,6 +22,7 @@ import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.integration.Message;
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
@@ -69,17 +70,28 @@ public class MqttPahoMessageDrivenChannelAdapter extends AbstractMqttMessageDriv
@Override
protected void doStop() {
this.cancelReconnect();
super.doStop();
try {
this.client.unsubscribe(this.getTopic());
this.client.disconnect();
this.client.close();
this.connected = false;
this.client = null;
}
catch (MqttException e) {
logger.error("Exception while unsubscribing and disconnecting", e);
logger.error("Exception while unsubscribing", e);
}
try {
this.client.disconnect();
}
catch (MqttException e) {
logger.error("Exception while disconnecting", e);
}
try {
this.client.close();
}
catch (MqttException e) {
logger.error("Exception while closing", e);
}
this.connected = false;
this.client = null;
}
private void connectAndSubscribe() throws MqttException {