本文整理汇总了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;
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例11: stop
import org.eclipse.paho.client.mqttv3.MqttException; //导入方法依赖的package包/类
@Override
public void stop() {
try {
client.disconnect();
} catch (MqttException e) {
e.printStackTrace();
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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");
}
示例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);
}