public void run() {
    Log.d(logTag, "Receiver started");
    receiverThread = Thread.currentThread();
    while (true) {
      try {

        if (connection != null) {
          Log.d(logTag, "Waiting for message from PCF...");
          final Message result = connection.receive().await();
          if (result != null) {
            Log.d(logTag, "Received message from PCF: " + new String(result.getPayload()));
            SessionManager.handlePatientResults(new String(result.getPayload()));
          }
        }

      } catch (Exception e) {
        if (die.get()) {
          // user initiated disconnect
          die.set(false);
        } else {
          // unexpected failure
          SessionManager.connectionFailure(host);
        }
        break;
      }
    }
    try {
      connection.disconnect().await();
      Log.d(logTag, "Receiver stopped");
    } catch (Exception e) {
      Log.e(logTag, e.getMessage());
    }
  }
 @Override
 public void run() {
   LOGGER.info("Started MQTT subscription processing thread.");
   while (true) {
     try {
       Future<Message> future = connection.receive();
       Message message = future.await();
       message.ack();
       EventProcessingLogic.processRawPayload(
           MqttInboundEventReceiver.this, message.getPayload(), null);
     } catch (InterruptedException e) {
       break;
     } catch (Throwable e) {
       LOGGER.error(e);
     }
   }
 }