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

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

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

MQTT.setWillQos介绍

暂无

代码示例

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

displayHelpAndExit(1);
  main.mqtt.setWillQos(QoS.values()[v]);
} else if ("--will-retain".equals(arg)) {
  main.mqtt.setWillRetain(true);

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

displayHelpAndExit(1);
  main.mqtt.setWillQos(QoS.values()[v]);
} else if ("--will-retain".equals(arg)) {
  main.mqtt.setWillRetain(true);

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

client.setWillQos(qos);
client.setWillTopic(options.getWillTopic());
client.setWillMessage(options.getWillPayload());

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

displayHelpAndExit(1);
  main.mqtt.setWillQos(QoS.values()[v]);
} else if ("--will-retain".equals(arg)) {
  main.mqtt.setWillRetain(true);

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

displayHelpAndExit(1);
  main.mqtt.setWillQos(QoS.values()[v]);
} else if ("--will-retain".equals(arg)) {
  main.mqtt.setWillRetain(true);

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

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

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

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

代码示例来源: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()));
}

相关文章