From 2a6e42b6466fcf0ef709ba0958cf9843793a3904 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sun, 24 Apr 2016 02:16:27 +0530 Subject: [PATCH] resolve server shutdown issues --- .../extensions/mqtt/MQTTEventAdapter.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/mqtt/MQTTEventAdapter.java b/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/mqtt/MQTTEventAdapter.java index e95cac9e..00c0494a 100644 --- a/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/mqtt/MQTTEventAdapter.java +++ b/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/mqtt/MQTTEventAdapter.java @@ -114,8 +114,20 @@ public class MQTTEventAdapter implements InputEventAdapter { @Override public void disconnect() { - if (mqttAdapterListener != null) { - mqttAdapterListener.stopListener(eventAdapterConfiguration.getName()); + //when mqtt and this feature both together then this method becomes a blocking method, Therefore + // have used a thread to skip it. + try { + Thread thread = new Thread(new Runnable() { + public void run() { + if (mqttAdapterListener != null) { + mqttAdapterListener.stopListener(eventAdapterConfiguration.getName()); + } + } + }); + thread.start(); + thread.join(2000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); } }