public void logController(String topic, MqttMessage mqttMessage) {
    // get deviceId
    String[] split = topic.split("log/");
    String deviceId = split[1];

    // parse log
    try {
      JsonReader reader = Json.createReader(new StringReader(mqttMessage.toString()));
      JsonObject jsonMessage = reader.readObject();
      String logType = jsonMessage.getString("type");
      switch (logType) {
        case LOG_NORMAL:
          int temperature = 0;
          int timer = jsonMessage.getInt("time");
          try {
            temperature = jsonMessage.getInt("temperature");
          } catch (Exception se1) {
            // @todo: warning
            break;
          }
          JsonString subDeviceId = jsonMessage.getJsonString("subId");
          if (subDeviceId == null) sessionHandle.drawTemperature(deviceId, timer, temperature);
          else sessionHandle.drawTemperature(deviceId, timer, temperature, subDeviceId.toString());
          break;
        case LOG_WARNING:
          timer = jsonMessage.getInt("time");
          subDeviceId = jsonMessage.getJsonString("subId");
          int subdeviceNo = jsonMessage.getInt("number");
          String deviceState = jsonMessage.getString("value");
          String msg;
          switch (subdeviceNo) {
            case 1:
              msg = ("0".equals(deviceState)) ? "Button release" : "Button clicked";
              break;
            case 2:
              msg = ("0".equals(deviceState)) ? "Cửa cuốn được cuộn lên" : "Đang thả cửa cuốn";
              break;
            default:
              msg = DEFAULT_ALERT_MSG;
              break;
          }
          if (subDeviceId == null) sessionHandle.doAlert(deviceId, timer, msg);
          else sessionHandle.doAlert(deviceId, timer, msg, subDeviceId.toString());
          break;
        case LOG_CONTROL:
          String state = jsonMessage.getString("light");
          subdeviceNo = jsonMessage.getInt("no");
          sessionHandle.updateLightState(deviceId, subdeviceNo, state);
          break;
        case LOG_ACK:
          subdeviceNo = jsonMessage.getInt("number");
          deviceState = jsonMessage.getString("value");
          state = ("0".equals(deviceState)) ? "off" : "on";
          sessionHandle.ackLightState(deviceId, subdeviceNo, state);
          break;
        case LOG_DEVICE_STATUS:
          JsonArray lstDevice = jsonMessage.getJsonArray("status");
          System.out.println("Update status:");
          for (int i = 0; i < lstDevice.size(); i++) {
            JsonObject device = (JsonObject) lstDevice.get(i);
            System.out.println(device.toString());
            subdeviceNo = device.getInt("no");
            int intState = device.getInt("value");
            state = (intState == 0) ? "off" : "on";
            sessionHandle.updateLightState(deviceId, subdeviceNo, state);
          }
          sessionHandle.finishUpdateDeviceStatus();
          break;
        default:
      }

    } catch (Exception ex) {
      System.out.println("Parse error");
      System.out.println(topic);
      System.out.println(mqttMessage);
      System.out.println(ex.getMessage());
    }
  }
  private static boolean loadATMSwitchConfig(String connId) throws Exception {

    InputStream is = null;
    boolean isLoadedFlag = false;
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    is = classLoader.getResource(atmSwitchConfigFileName).openStream();

    if (is == null) {
      throw new Exception("Unable to load config file - " + atmSwitchConfigFileName);
    }

    try {
      JsonReader jsonReader = Json.createReader(is);
      JsonObject allConfigs = jsonReader.readObject();
      JsonString logFileLocation = allConfigs.getJsonString(logFileLocationKey);
      if (logFileLocation == null) {
        throw new Exception(logFileLocationKey + " parameter missing in the configuration....");
      }
      if ("".equals(connId))
        logger =
            (new AsynchLogger(logFileLocation.toString() + "/ISOSysLog", Level.INFO))
                .getLogger("ISOSysLog");

      JsonArray serverConfigs = allConfigs.getJsonArray(serverConfigKey);
      if (serverConfigs == null) {
        throw new Exception(
            serverConfigKey + " parameter missing. No server Configurations specified....");
      }
      logger.info("Initializing ATM Switch Configuration....");

      if (manifestAttrs != null && "".equals(connId)) {

        logger.info(
            "Build version "
                + manifestAttrs.getValue("Implementation-Version")
                + " Build Date "
                + manifestAttrs.getValue("Build-Time"));
      }

      for (int i = 0; i < serverConfigs.size(); i++) {

        JsonObject serverConfig = serverConfigs.getJsonObject(i);
        JsonString host = serverConfig.getJsonString(serverHostKey);
        JsonNumber port = serverConfig.getJsonNumber(portKey);
        JsonNumber connTimeOut = serverConfig.getJsonNumber(connTimeOutKey);
        JsonNumber readTimeOut = serverConfig.getJsonNumber(readTimeOutKey);
        JsonNumber retry = serverConfig.getJsonNumber(retryKey);
        JsonNumber threadTimeOut = serverConfig.getJsonNumber(threadTimeOutKey);
        JsonString logLevelJson = serverConfig.getJsonString(loglevelKey);
        JsonNumber echoTimeInterval = serverConfig.getJsonNumber(echoTimeIntervalKey);
        JsonString uidFormat = serverConfig.getJsonString("uidFormat");

        if (host == null || port == null) {
          logger.error(
              serverConfig
                  + " Bad configuration for connection ( Host OR Port is missing ). Not Loading this connection....");
          continue;
        }
        if (uidFormat == null) {
          logger.error(
              serverConfig
                  + " Bad configuration for connection ( uidFormat is missing ). Not Loading this connection....");
          continue;
        }

        Level level = null;
        if (logLevelJson == null) {
          level = Level.INFO;
        } else {
          String logLevel = logLevelJson.getString();
          if (logLevel.equalsIgnoreCase("TRACE")) {
            level = Level.TRACE;
          } else if (logLevel.equalsIgnoreCase("DEBUG")) {
            level = Level.DEBUG;
          } else {
            level = Level.INFO;
          }
        }
        MessageUIDGenerator messageUIDGenerator =
            MessageUIDGeneratorFactory.getMessageUIDGenerator(uidFormat.toString());
        if (!"".equals(connId)) {
          if (!connId.equalsIgnoreCase(host.getString() + "_" + port.intValue())) {
            continue;
          }
        }
        ATMSwitchTCPHandler.manualStopPool.put(
            host.getString() + "_" + String.valueOf(port.intValue()), Boolean.FALSE);
        ConnectionBean bean =
            new ConnectionBean(
                host.getString(),
                port.intValue(),
                (connTimeOut == null ? 8000 : connTimeOut.intValue()),
                (readTimeOut == null ? 8000 : readTimeOut.intValue()),
                (threadTimeOut == null ? 5000 : threadTimeOut.intValue()),
                (retry == null ? 3 : retry.intValue()),
                (echoTimeInterval == null ? 0 : echoTimeInterval.intValue()));

        ServerContainer container =
            new ServerContainer(bean, logFileLocation.getString(), level, messageUIDGenerator);
        try {
          if (container.connect(false)) {
            logger.info(bean.toString() + " Loaded....");
            isLoadedFlag = true;
          } else {
            logger.warn(bean.toString() + " could not be loaded....");
          }
        } catch (InterruptedException e) {
          logger.error(
              "( "
                  + bean.getUniqueName()
                  + " ,loadAllClientConnection(, ,) ) Interrupted Exception",
              e);
        } catch (ExecutionException e) {
          logger.error(
              "( " + bean.getUniqueName() + " ,loadAllClientConnection(, ,) ) ExecutionException",
              e);
        } catch (IOException e) {
          logger.error(
              "( " + bean.getUniqueName() + " ,loadAllClientConnection(, ,) ) IOException", e);
        } catch (Exception e) {
          logger.error(
              "( " + bean.getUniqueName() + " ,loadAllClientConnection(, ,) ) Exception", e);
        }
      }

    } finally {
      if (is != null) {
        try {
          is.close();
        } catch (IOException e) {
          logger.error("IOException in closing the stream for JSON config property file....", e);
        }
      }
    }
    return isLoadedFlag;
  }