INTEXT-89 Fix Inbound Stop When No Server
The reconnection task was not canceled in doStop().
This commit is contained in:
@@ -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'
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user