public void messageArrived(String topic, MqttMessage mqttMessage) throws MqttException { if (log.isDebugEnabled()) { log.debug("Received Message: Topic:" + topic + " Message: " + mqttMessage); } log.info("Received Message: Topic: " + topic); injectHandler.invoke(mqttMessage); }
private void connect() { boolean tryConnecting = true; while (tryConnecting) { try { MqttClient mqttClient = confac.getMqttClient(); mqttClient.connect(); setParams(params); setMsg(msg); setMqttSyncCallback(confac); listener1 = new InboundRequestProcessorFactoryImpl(); if (mqttClient.isConnected()) { if (confac.getTopic() != null) { mqttClient.subscribe(confac.getTopic()); log.info("Subscribed to the remote server."); } tryConnecting = false; injectHandler.invoke(msg); return; } } catch (Exception e1) { log.error("Connection attempt failed with '" + e1.getCause() + "'. Retrying."); pause(); } } }