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

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

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

MQTT.setWillRetain介绍

暂无

代码示例

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

main.mqtt.setWillRetain(true);
} else if ("-d".equals(arg)) {
  main.debug = true;

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

main.mqtt.setWillRetain(true);
} else if ("-d".equals(arg)) {
  main.debug = true;

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

client.setWillTopic(options.getWillTopic());
client.setWillMessage(options.getWillPayload());
client.setWillRetain(options.getWillRetain());

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

mqtt.setHost("localhost", 1883);
mqtt.setClientId("WillTestamentPublisher");
mqtt.setWillRetain(false);
mqtt.setWillMessage(willTestamentMsg);
mqtt.setWillTopic(willTestamentTopic);

代码示例来源: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.setWillRetain(true);
} else if ("-d".equals(arg)) {
  main.debug = true;

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

main.mqtt.setWillRetain(true);
} else if ("-d".equals(arg)) {
  main.debug = true;

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

client.setWillMessage(mqttClientConfig.getWillMessage());
client.setWillQos(mqttClientConfig.getWillQos());
client.setWillRetain(mqttClientConfig.isWillRetain());

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

client.setWillMessage(mqttClientConfig.getWillMessage());
client.setWillQos(mqttClientConfig.getWillQos());
client.setWillRetain(mqttClientConfig.isWillRetain());

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

client.setWillMessage(mqttClientConfig.getWillMessage());
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 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()));
}

相关文章