当前位置: 首页>>代码示例>>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;未经允许,请勿转载。