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

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

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

MQTT.setConnectAttemptsMax介绍

暂无

代码示例

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

client.setReconnectDelayMax(options.getReconnectDelayMax());
client.setReconnectBackOffMultiplier(options.getReconnectBackOffMultiplier());
client.setConnectAttemptsMax(options.getConnectAttemptsMax());
client.setReconnectAttemptsMax(options.getReconnectAttemptsMax());

代码示例来源:origin: PerfCake/PerfCake

final MQTT mqttClient = new MQTT();
mqttClient.setHost(protocol + "://" + host + ":" + port);
mqttClient.setConnectAttemptsMax(0);
mqttClient.setReconnectAttemptsMax(0);
if (userName != null) {
   mqttResponseClient.setConnectAttemptsMax(0);
   mqttResponseClient.setReconnectAttemptsMax(0);
   if (responseUserName != null) {

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

@Override
public void connect(String host) throws Exception {
 mqtt.setHost(host);
 mqtt.setVersion("3.1.1");
 // shut off connect retry
 mqtt.setConnectAttemptsMax(0);
 mqtt.setReconnectAttemptsMax(0);
 connection = mqtt.blockingConnection();
 connection.connect();
}

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

private MQTT createMQTTSslConnection(String clientId, boolean clean) throws Exception {
 MQTT mqtt = new MQTT();
 mqtt.setConnectAttemptsMax(1);
 mqtt.setReconnectAttemptsMax(0);
 mqtt.setTracer(createTracer());
 mqtt.setHost("ssl://localhost:" + port);
 if (clientId != null) {
   mqtt.setClientId(clientId);
 }
 mqtt.setCleanSession(clean);
 SSLContext ctx = SSLContext.getInstance("TLS");
 ctx.init(new KeyManager[0], new TrustManager[]{new DefaultTrustManager()}, new SecureRandom());
 mqtt.setSslContext(ctx);
 return mqtt;
}

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

private MQTT createMQTTTcpConnection(String clientId, boolean clean) throws Exception {
 MQTT mqtt = new MQTT();
 mqtt.setConnectAttemptsMax(1);
 mqtt.setReconnectAttemptsMax(0);
 mqtt.setTracer(createTracer());
 mqtt.setVersion("3.1.1");
 if (clientId != null) {
   mqtt.setClientId(clientId);
 }
 mqtt.setCleanSession(clean);
 mqtt.setHost("localhost", port);
 return mqtt;
}

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

@Test
public void testConnectWithLargePassword() throws Exception {
 for (String version : Arrays.asList("3.1", "3.1.1")) {
   String longString = new String(new char[65535]);
   BlockingConnection connection = null;
   try {
    MQTT mqtt = createMQTTConnection("test-" + version, true);
    mqtt.setUserName(longString);
    mqtt.setPassword(longString);
    mqtt.setConnectAttemptsMax(1);
    mqtt.setVersion(version);
    connection = mqtt.blockingConnection();
    connection.connect();
    BlockingConnection finalConnection = connection;
    assertTrue("Should be connected", Wait.waitFor(() -> finalConnection.isConnected(), 5000, 100));
   } finally {
    if (connection != null && connection.isConnected()) connection.disconnect();
   }
 }
}

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

client.setConnectAttemptsMax(mqttClientConfig.getConnectAttemptsMax());
client.setHost(mqttClientConfig.getHost(), mqttClientConfig.getPort());
client.setKeepAlive(mqttClientConfig.getKeepAliveInterval());

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

@Test(timeout = 30000, expected = EOFException.class)
  public void testConnectionWithNullPassword() throws Exception {
   for (String version : Arrays.asList("3.1", "3.1.1")) {

     BlockingConnection connection = null;
     try {
      MQTT mqtt = createMQTTConnection("test-" + version, true);
      mqtt.setUserName(fullUser);
      mqtt.setPassword((String) null);
      mqtt.setConnectAttemptsMax(1);
      mqtt.setVersion(version);
      connection = mqtt.blockingConnection();
      connection.connect();
      fail("Connect should fail");
     } finally {
      if (connection != null && connection.isConnected()) connection.disconnect();
     }
   }
  }
}

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

client.setConnectAttemptsMax(mqttClientConfig.getConnectAttemptsMax());
client.setHost(mqttClientConfig.getHost(), mqttClientConfig.getPort());
client.setKeepAlive(mqttClientConfig.getKeepAliveInterval());

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

@Test(timeout = 30000)
public void testConnection() throws Exception {
 for (String version : Arrays.asList("3.1", "3.1.1")) {
   BlockingConnection connection = null;
   try {
    MQTT mqtt = createMQTTConnection("test-" + version, true);
    mqtt.setUserName(fullUser);
    mqtt.setPassword(fullPass);
    mqtt.setConnectAttemptsMax(1);
    mqtt.setVersion(version);
    connection = mqtt.blockingConnection();
    connection.connect();
    BlockingConnection finalConnection = connection;
    assertTrue("Should be connected", Wait.waitFor(() -> finalConnection.isConnected(), 5000, 100));
   } finally {
    if (connection != null && connection.isConnected()) connection.disconnect();
   }
 }
}

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

private BlockingConnection retrieveMQTTConnection(String host, String truststorePath, String truststorePass, String keystorePath, String keystorePass) throws Exception {
 MQTT mqtt = new MQTT();
 mqtt.setConnectAttemptsMax(1);
 mqtt.setReconnectAttemptsMax(0);
 mqtt.setHost(host);
 SSLContext sslContext = new SSLSupport()
   .setKeystorePath(keystorePath)
   .setKeystorePassword(keystorePass)
   .setTruststorePath(truststorePath)
   .setTruststorePassword(truststorePass)
   .createContext();
 mqtt.setSslContext(sslContext);
 BlockingConnection connection = mqtt.blockingConnection();
 connection.connect();
 return connection;
}

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

client.setConnectAttemptsMax(mqttClientConfig.getConnectAttemptsMax());
client.setHost(mqttClientConfig.getHost(), mqttClientConfig.getPort());
client.setKeepAlive(mqttClientConfig.getKeepAliveInterval());

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

相关文章