org.fusesource.mqtt.client.MQTT.setWillTopic()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.fusesource.mqtt.client.MQTT.setWillTopic()方法的一些代码示例,展示了MQTT.setWillTopic()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MQTT.setWillTopic()方法的具体详情如下:
包路径:org.fusesource.mqtt.client.MQTT
类名称:MQTT
方法名:setWillTopic

MQTT.setWillTopic介绍

暂无

代码示例

代码示例来源:origin: fusesource/mqtt-client

public void setWillTopic(String willTopic) {
  this.setWillTopic(utf8(willTopic));
}
public void setWillTopic(UTF8Buffer willTopic) {

代码示例来源:origin: fusesource/mqtt-client

main.mqtt.setPassword(shift(argl));
} else if ("--will-topic".equals(arg)) {
  main.mqtt.setWillTopic(shift(argl));
} else if ("--will-payload".equals(arg)) {
  main.mqtt.setWillMessage(shift(argl));

代码示例来源:origin: fusesource/mqtt-client

main.mqtt.setPassword(shift(argl));
} else if ("--will-topic".equals(arg)) {
  main.mqtt.setWillTopic(shift(argl));
} else if ("--will-payload".equals(arg)) {
  main.mqtt.setWillMessage(shift(argl));

代码示例来源:origin: apache/storm

QoS qos = MqttUtils.qosFromInt(options.getWillQos());
client.setWillQos(qos);
client.setWillTopic(options.getWillTopic());
client.setWillMessage(options.getWillPayload());
client.setWillRetain(options.getWillRetain());

代码示例来源:origin: andsel/moquette

mqtt.setWillRetain(false);
mqtt.setWillMessage(willTestamentMsg);
mqtt.setWillTopic(willTestamentTopic);
m_publisher = mqtt.blockingConnection();
m_publisher.connect();

代码示例来源:origin: apache/activemq-artemis

@Override
public void setWillTopic(String topic) {
 mqtt.setWillTopic(topic);
}

代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client

public void setWillTopic(String willTopic) {
  this.setWillTopic(utf8(willTopic));
}
public void setWillTopic(UTF8Buffer willTopic) {

代码示例来源:origin: stackoverflow.com

try{
  MqttMessage message2 = new MqttMessage();
  MQTT mqtt_connect = new MQTT();
  mqtt_connect.setHost(Host_Address, Integer.parseInt(port));
  String topic = "/call/MQTT_Config";
  mqtt_connect.setClientId("MQTT_Config");
  mqtt_connect.setWillRetain(false);
  mqtt_connect.isWillRetain();
  mqtt_connect.setWillTopic(topic);
  BlockingConnection m_publisher = mqtt_connect.blockingConnection();
  m_publisher.connect();

}
catch(Exception e){
  add message for connection not established
}

代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client

main.mqtt.setPassword(shift(argl));
} else if ("--will-topic".equals(arg)) {
  main.mqtt.setWillTopic(shift(argl));
} else if ("--will-payload".equals(arg)) {
  main.mqtt.setWillMessage(shift(argl));

代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client

main.mqtt.setPassword(shift(argl));
} else if ("--will-topic".equals(arg)) {
  main.mqtt.setWillTopic(shift(argl));
} else if ("--will-payload".equals(arg)) {
  main.mqtt.setWillMessage(shift(argl));

代码示例来源:origin: apache/apex-malhar

client.setWillTopic(mqttClientConfig.getWillTopic());

代码示例来源:origin: org.apache.apex/malhar-contrib

client.setWillTopic(mqttClientConfig.getWillTopic());

代码示例来源:origin: org.apache.apex/malhar-contrib

client.setWillQos(mqttClientConfig.getWillQos());
client.setWillRetain(mqttClientConfig.isWillRetain());
client.setWillTopic(mqttClientConfig.getWillTopic());

代码示例来源:origin: apache/apex-malhar

@Override
public void setup(OperatorContext context)
{
 try {
  client = new MQTT();
  if (mqttClientConfig.getClientId() != null) {
   client.setClientId(mqttClientConfig.getClientId());
  }
  client.setCleanSession(mqttClientConfig.isCleanSession());
  client.setConnectAttemptsMax(mqttClientConfig.getConnectAttemptsMax());
  client.setHost(mqttClientConfig.getHost(), mqttClientConfig.getPort());
  client.setKeepAlive(mqttClientConfig.getKeepAliveInterval());
  if (mqttClientConfig.getPassword() != null) {
   client.setPassword(mqttClientConfig.getPassword());
  }
  if (mqttClientConfig.getUserName() != null) {
   client.setUserName(mqttClientConfig.getUserName());
  }
  if (mqttClientConfig.getWillMessage() != null) {
   client.setWillMessage(mqttClientConfig.getWillMessage());
   client.setWillQos(mqttClientConfig.getWillQos());
   client.setWillRetain(mqttClientConfig.isWillRetain());
   client.setWillTopic(mqttClientConfig.getWillTopic());
  }
  connection = client.blockingConnection();
  connection.connect();
 } catch (Throwable t) {
  throw new RuntimeException(t);
 }
}

代码示例来源:origin: apache/activemq-artemis

@Test(timeout = 60 * 1000)
public void testClientConnectionFailureSendsWillMessage() throws Exception {
 getServer().createQueue(SimpleString.toSimpleString("will"), RoutingType.MULTICAST, SimpleString.toSimpleString("will"), null, true, false);
 MQTT mqtt = createMQTTConnection("1", false);
 mqtt.setKeepAlive((short) 1);
 mqtt.setWillMessage("test message");
 mqtt.setWillTopic("will");
 mqtt.setWillQos(QoS.AT_LEAST_ONCE);
 final BlockingConnection connection = mqtt.blockingConnection();
 connection.connect();
 Wait.waitFor(() -> connection.isConnected());
 MQTT mqtt2 = createMQTTConnection("2", false);
 BlockingConnection connection2 = mqtt2.blockingConnection();
 connection2.connect();
 connection2.subscribe(new Topic[]{new Topic("will", QoS.AT_LEAST_ONCE)});
 // kill transport
 connection.kill();
 // FIXME Wait for the previous connection to timeout.  This is not required in ActiveMQ.  Needs investigating.
 Thread.sleep(10000);
 Message m = connection2.receive(1000, TimeUnit.MILLISECONDS);
 assertEquals("test message", new String(m.getPayload()));
}

代码示例来源:origin: apache/activemq-artemis

@Test(timeout = 60 * 1000)
public void testWillMessageIsRetained() throws Exception {
 getServer().createQueue(SimpleString.toSimpleString("will"), RoutingType.MULTICAST, SimpleString.toSimpleString("will"), null, true, false);
 MQTT mqtt = createMQTTConnection("1", false);
 mqtt.setKeepAlive((short) 1);
 mqtt.setWillMessage("test message");
 mqtt.setWillTopic("will");
 mqtt.setWillQos(QoS.AT_LEAST_ONCE);
 mqtt.setWillRetain(true);
 final BlockingConnection connection = mqtt.blockingConnection();
 connection.connect();
 Wait.waitFor(() -> connection.isConnected());
 // kill transport
 connection.kill();
 Thread.sleep(10000);
 MQTT mqtt2 = createMQTTConnection("2", false);
 BlockingConnection connection2 = mqtt2.blockingConnection();
 connection2.connect();
 connection2.subscribe(new Topic[]{new Topic("will", QoS.AT_LEAST_ONCE)});
 Message m = connection2.receive(1000, TimeUnit.MILLISECONDS);
 assertNotNull(m);
 m.ack();
 assertEquals("test message", new String(m.getPayload()));
}

相关文章