use of org.fusesource.mqtt.client.Promise in project camel by apache.
the class MQTTEndpoint method doStop.
@Override
protected void doStop() throws Exception {
super.doStop();
if (connection != null && connected) {
final Promise<Void> promise = new Promise<>();
connection.getDispatchQueue().execute(new Task() {
@Override
public void run() {
connection.disconnect(new Callback<Void>() {
public void onSuccess(Void value) {
connected = false;
promise.onSuccess(value);
}
public void onFailure(Throwable value) {
promise.onFailure(value);
}
});
}
});
promise.await(configuration.getDisconnectWaitInSeconds(), TimeUnit.SECONDS);
}
}