當前位置: 首頁>>代碼示例>>Java>>正文


Java MqttException.printStackTrace方法代碼示例

本文整理匯總了Java中org.eclipse.paho.client.mqttv3.MqttException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java MqttException.printStackTrace方法的具體用法?Java MqttException.printStackTrace怎麽用?Java MqttException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.paho.client.mqttv3.MqttException的用法示例。


在下文中一共展示了MqttException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startListening

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
private void startListening() {
  logger.debug("Starting listening for incoming traffic");
  try {
    String url =
        incomingMqttBrokerProtocol + "://" + incomingMqttBroker + ":" + incomingMqttBrokerPort;
    client = new MqttClient(url, incomingMqttClientId);
    MqttConnectOptions connOpts = new MqttConnectOptions();
    connOpts.setUserName(incomingMqttUser);
    connOpts.setPassword(incomingMqttPassword.toCharArray());
    connOpts.setCleanSession(true);
    connOpts.setKeepAliveInterval(incomingMqttKeepAlive);
    logger.debug("Connecting to incoming message broker:  " + incomingMqttBroker);
    client.connect(connOpts);
    logger.debug("Connected to incoming message broker");
    client.setCallback(this);
    client.subscribe(incomingMqttTopic, incomingMqttQos);
  } catch (MqttException e) {
    logger.error("Unable to connect to incoming message queue.");
    e.printStackTrace();
    client = null;
  }
}
 
開發者ID:edgexfoundry,項目名稱:device-mqtt,代碼行數:23,代碼來源:IncomingListener.java

示例2: MqttClientKetiSub

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
public MqttClientKetiSub(String serverUrl) {
	
	this.mqttServerUrl = serverUrl;
	
	System.out.println("[KETI MQTT Client] Client Initialize");
	
	try {
		mqc = new MqttClient(mqttServerUrl, mqttClientId, persistence);
		
		while(!mqc.isConnected()){
			mqc.connect();
			System.out.println("[KETI MQTT Client] Connection try");
		}
		
		System.out.println("[KETI MQTT Client] Connected to Server - " + mqttServerUrl);
	} catch (MqttException e) {
		e.printStackTrace();
	}
}
 
開發者ID:IoTKETI,項目名稱:nCube-Thyme-Java,代碼行數:20,代碼來源:MqttClientKetiSub.java

示例3: MqttClientKetiPub

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
public MqttClientKetiPub(String serverUrl) {
	
	this.mqttServerUrl = serverUrl;
	
	System.out.println("[KETI MQTT Client] Client Initialize");
	
	try {
		mqc = new MqttClient(mqttServerUrl, mqttClientId, persistence);
		
		while(!mqc.isConnected()){
			mqc.connect();
			System.out.println("[KETI MQTT Client] Connection try");
		}
		
		System.out.println("[KETI MQTT Client] Connected to Server - " + mqttServerUrl);
	} catch (MqttException e) {
		e.printStackTrace();
	}
}
 
開發者ID:IoTKETI,項目名稱:nCube-Thyme-Java,代碼行數:20,代碼來源:MqttClientKetiPub.java

示例4: connectClient

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
private void connectClient() {
  try {
    client = new MqttClient(broker, clientId);
    client.setCallback(this);
    MqttConnectOptions connOpts = new MqttConnectOptions();
    connOpts.setUserName(user);
    connOpts.setPassword(password.toCharArray());
    connOpts.setCleanSession(true);
    connOpts.setKeepAliveInterval(OUTGOING_MQTT_KEEP_ALIVE);
    logger.debug("Connecting to broker:  " + broker);
    client.connect(connOpts);
    logger.debug("Connected");
  } catch (MqttException e) {
    logger.error("Failed to connect to MQTT client ( " + broker + "/" + clientId
        + ") for outbound messages");
    logger.error(e.getLocalizedMessage());
    e.printStackTrace();
  }
}
 
開發者ID:edgexfoundry,項目名稱:device-mqtt,代碼行數:20,代碼來源:OutgoingSender.java

示例5: connectionLost

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
@Override
public void connectionLost(Throwable cause) {
  logger.error("Incoming subscription connection lost:" + cause.getLocalizedMessage());
  // cause.printStackTrace();
  try {
    client.close();
  } catch (MqttException e) {
    logger.error("Unable to close the client.");
    e.printStackTrace();
  }
  startListening();
}
 
開發者ID:edgexfoundry,項目名稱:device-mqtt,代碼行數:13,代碼來源:IncomingListener.java

示例6: closeClient

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
public void closeClient() {
	try {
		if (client != null) {
			client.disconnect();
			client.close();
		}
	} catch (MqttException e) {
		logger.error("Problems disconnecting and closing the client.");
		e.printStackTrace();
	}
}
 
開發者ID:edgexfoundry,項目名稱:export-distro,代碼行數:12,代碼來源:MQTTSender.java

示例7: messageArrived

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
@Override
public void messageArrived(String topic, MqttMessage message) throws Exception {

    Log.d(TAG, "messageArrived");

    textViewData.setText("");
    textViewData.setText("**** MQTT CO2 실시간 조회 ****\r\n\r\n" + message.toString().replaceAll("\t|\n", ""));
    //Log.d(TAG, "topic:" + topic);
    //Log.d(TAG, "ResMessage:" + message.toString());
    String retrqi = MqttClientRequestParser.notificationJsonParse(message.toString());
    String responseMessage = MqttClientRequest.notificationResponse(retrqi);

    /* xml parsing
    ArrayList<String> mqttMessage = new ArrayList<String>();

    Log.d(TAG, "ResMessage:" + message.toString());

    mqttMessage = MqttClientRequestParser.notificationParse(message.toString());

    Log.d(TAG, "***************************");
    String responseMessage = MqttClientRequest.notificationResponse(mqttMessage);
    */
    //Log.d(TAG, "MQTT Resp["+responseMessage+"]");
    /* Make xml for MQTT Response Message */
    MqttMessage resmessage = new MqttMessage(responseMessage.getBytes());

    try {
        mqttClient.publish(MQTT_Resp_Topic, resmessage);
    } catch (MqttException e) {
        e.printStackTrace();
    }
}
 
開發者ID:IoTKETI,項目名稱:oneM2M-Application-AndroidSample,代碼行數:33,代碼來源:MainActivity.java

示例8: onSuccess

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
@Override
public void onSuccess(IMqttToken asyncActionToken) {
    Log.d(TAG, "onSuccess");
    String payload = "";
    int mqttQos = 1; /* 0: NO QoS, 1: No Check , 2: Each Check */

    MqttMessage message = new MqttMessage(payload.getBytes());
    try {
        mqttClient.subscribe(MQTT_Req_Topic, mqttQos);
    } catch (MqttException e) {
        e.printStackTrace();
    }
}
 
開發者ID:IoTKETI,項目名稱:oneM2M-Application-AndroidSample,代碼行數:14,代碼來源:MainActivity.java

示例9: stopDag

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
public boolean stopDag() {
    try {
        mqttClient.connect();
        stopArtifactsAndPurgeConnections();
        removeArtifacts();
        mqttClient.disconnect();
    } catch(MqttException e ) {
        e.printStackTrace();
    }
    // stop all processors and ports and rpgs, purge all connections.
    // remove all connections.
    // remove all processors and ports and rpgs.
    return true;
}
 
開發者ID:dream-lab,項目名稱:echo,代碼行數:15,代碼來源:NifiDeployer.java

示例10: deployDag

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
public DataflowInput deployDag(Map<Processor, Device> placementMap,
                               DataflowInput input) {

    this.processorMapping = placementMap;
    for (Map.Entry<Processor, Device> entry : this.processorMapping.entrySet()) {
        System.out.println(entry.getValue().getDeviceIP());
    }

    MqttConnectOptions connOpts = new MqttConnectOptions();
    connOpts.setCleanSession(true);
    try {
        mqttClient.connect();

        populateMaps(input.getWiring(), placementMap);

        createProcessorsPortsAndRPGs();
        createConnections();
        startAllPorts();
        createRemoteConnections();
        startAllProcessors();

        mqttClient.disconnect();
    } catch (MqttException e) {
        e.printStackTrace();
    }
    return input;
}
 
開發者ID:dream-lab,項目名稱:echo,代碼行數:28,代碼來源:NifiDeployer.java

示例11: stop

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
@Override
public void stop() {
    try {
        client.disconnect();
    } catch (MqttException e) {
        e.printStackTrace();
    }
}
 
開發者ID:datathings,項目名稱:greycat,代碼行數:9,代碼來源:MQTTPlugin.java

示例12: close

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
public void close(){
	if (client.isConnected()){
		try {
			client.disconnect();
			log.info("CLIENT DISCONNECTION");
			messages.add("CLIENT DISCONNECTION");
			client.close();
			log.info("CLIENT CLOSING");
			messages.add("CLIENT CLOSING");
		} catch (MqttException e) {
			e.printStackTrace();
		}
	}
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:15,代碼來源:MqttCallBackImpl.java

示例13: publishMessage

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
private void publishMessage(byte[] message, String topicPostfix){
    if (mqttAndroidClient != null && mqttAndroidClient.isConnected()) {
        try {
            String test = new String(message, StandardCharsets.UTF_8);
            Log.i(TAG,test);
            mqttAndroidClient.publish(topicPrefix+"sensor/"+topicPostfix, message, 0, false);

        } catch (MqttException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:ray0711,項目名稱:homeDash,代碼行數:13,代碼來源:HomeDashService.java

示例14: mqtt_disconnect

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
public void mqtt_disconnect() {
    if (mqttClient != null) {
        try {
            if (mqttClient.isConnected()) {
                Log.d(TAG, "Disconnecting MQTT");
                mqttClient.disconnect();
            }
            mqttClient.close();
        } catch (MqttException e) {
            e.printStackTrace();
        }
    }
    Log.d(TAG, "MQTT disconnected");
}
 
開發者ID:jpmeijers,項目名稱:ttnmapper_android_v2,代碼行數:15,代碼來源:TTNMapperService.java

示例15: subscribe

import org.eclipse.paho.client.mqttv3.MqttException; //導入方法依賴的package包/類
/**
 * subscribe Method
 * Subscribe to MQTT Broker
 * @param mqttTopic
 */
public void subscribe(String mqttTopic) {
	try {
		this.mqttTopicName = mqttTopic;
		mqc.subscribe(this.mqttTopicName);
		System.out.println("[KETI MQTT Client] Subscribe Success - " + mqttTopic);
	} catch (MqttException e) {
		System.out.println("[KETI MQTT Client] Subscribe Failed - " + mqttTopic);
		e.printStackTrace();
	}
	mqc.setCallback(this);
}
 
開發者ID:IoTKETI,項目名稱:nCube-Thyme-Java,代碼行數:17,代碼來源:MqttClientKetiPub.java


注:本文中的org.eclipse.paho.client.mqttv3.MqttException.printStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。