本文整理匯總了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);
}