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

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

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

MQTT.setHost介绍

暂无

代码示例

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

  1. public void setHost(String host) throws URISyntaxException {
  2. this.setHost(new URI(host));
  3. }
  4. public void setHost(URI host) {

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

  1. public void setHost(String host, int port) throws URISyntaxException {
  2. this.setHost(new URI("tcp://"+host+":"+port));
  3. }
  4. public void setHost(String host) throws URISyntaxException {

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

  1. /**
  2. * Initializes {@code connection}.
  3. * @throws Exception if an exception during connecting to connector occurs
  4. */
  5. public static void startPublisher() throws Exception {
  6. MQTT client = new MQTT();
  7. client.setTracer(new MqttLogger());
  8. client.setHost("tcp://localhost:1883");
  9. client.setClientId("MqttBrokerPublisher");
  10. connection = client.blockingConnection();
  11. Runtime.getRuntime().addShutdownHook(new Thread() {
  12. @Override
  13. public void run() {
  14. try {
  15. LOG.info("Shutting down MQTT client...");
  16. connection.disconnect();
  17. } catch (Exception e) {
  18. e.printStackTrace();
  19. }
  20. }
  21. });
  22. connection.connect();
  23. }

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

  1. @Before
  2. public void setUp() throws Exception {
  3. startServer();
  4. m_mqtt = new MQTT();
  5. m_mqtt.setHost("localhost", 1883);
  6. }

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

  1. main.mqtt.setVersion(shift(argl));
  2. } else if ("-h".equals(arg)) {
  3. main.mqtt.setHost(shift(argl));
  4. } else if ("-k".equals(arg)) {
  5. main.mqtt.setKeepAlive(Short.parseShort(shift(argl)));

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

  1. main.mqtt.setVersion(shift(argl));
  2. } else if ("-h".equals(arg)) {
  3. main.mqtt.setHost(shift(argl));
  4. } else if ("-k".equals(arg)) {
  5. main.mqtt.setKeepAlive(Short.parseShort(shift(argl)));

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

  1. URI uri = URI.create(options.getUrl());
  2. client.setHost(uri);
  3. if (!uri.getScheme().toLowerCase().equals("tcp")) {
  4. client.setSslContext(SslUtils.sslContext(uri.getScheme(), keyStoreLoader));

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

  1. mqtt.setHost("localhost", 1883);
  2. mqtt.setClientId("WillTestamentPublisher");
  3. mqtt.setWillRetain(false);
  4. m_publisher.connect();
  5. m_mqtt.setHost("localhost", 1883);
  6. m_mqtt.setCleanSession(false);
  7. m_mqtt.setClientId("Subscriber");

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

  1. public void setHost(String host, int port) throws URISyntaxException {
  2. this.setHost(new URI("tcp://"+host+":"+port));
  3. }
  4. public void setHost(String host) throws URISyntaxException {

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

  1. public void setHost(String host) throws URISyntaxException {
  2. this.setHost(new URI(host));
  3. }
  4. public void setHost(URI host) {

代码示例来源:origin: tuanhiep/mqtt-jmeter

  1. private FutureConnection createConnection(String host,String clientId) {
  2. try {
  3. MQTT client = new MQTT();
  4. client.setHost(host);
  5. client.setClientId(clientId);
  6. return client.futureConnection();
  7. } catch (URISyntaxException e) {
  8. getLogger().error(e.getMessage());
  9. return null;
  10. }
  11. }
  12. private FutureConnection createConnection(String host,String clientId,String user, String password) {

代码示例来源:origin: dempeZheng/forest-chat

  1. public void init(String host, int port) throws Exception {
  2. mqtt = new MQTT();
  3. mqtt.setHost(host, port);
  4. mqtt.setUserName(uid);
  5. mqtt.setPassword(pwd);
  6. mqtt.setClientId(uid);
  7. }

代码示例来源:origin: tuanhiep/mqtt-jmeter

  1. private CallbackConnection createConnection(String host, String clientId,
  2. boolean durable) throws URISyntaxException {
  3. MQTT client = new MQTT();
  4. client.setHost(host);
  5. client.setClientId(clientId);
  6. client.setCleanSession(!durable);
  7. return client.callbackConnection();
  8. }

代码示例来源:origin: tuanhiep/mqtt-jmeter

  1. private FutureConnection createConnection(String host,String clientId,String user, String password) {
  2. try {
  3. MQTT client = new MQTT();
  4. client.setHost(host);
  5. client.setUserName(user);
  6. client.setPassword(password);
  7. client.setClientId(clientId);
  8. return client.futureConnection();
  9. } catch (URISyntaxException e) {
  10. getLogger().error(e.getMessage());
  11. return null;
  12. }
  13. }

代码示例来源:origin: tuanhiep/mqtt-jmeter

  1. private CallbackConnection createConnection(String host, String clientId,
  2. boolean durable, String user, String password)
  3. throws URISyntaxException {
  4. MQTT client = new MQTT();
  5. client.setHost(host);
  6. client.setClientId(clientId);
  7. client.setUserName(user);
  8. client.setPassword(password);
  9. client.setCleanSession(!durable);
  10. return client.callbackConnection();
  11. }

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

  1. private static BlockingConnection retrieveMQTTConnection(String host) throws Exception {
  2. MQTT mqtt = new MQTT();
  3. mqtt.setHost(host);
  4. BlockingConnection connection = mqtt.blockingConnection();
  5. connection.connect();
  6. return connection;
  7. }
  8. }

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

  1. private static BlockingConnection retrieveMQTTConnection(String host) throws Exception {
  2. MQTT mqtt = new MQTT();
  3. mqtt.setHost(host);
  4. BlockingConnection connection = mqtt.blockingConnection();
  5. connection.connect();
  6. return connection;
  7. }

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

  1. @Override
  2. public void connect(String host) throws Exception {
  3. mqtt.setHost(host);
  4. mqtt.setVersion("3.1.1");
  5. // shut off connect retry
  6. mqtt.setConnectAttemptsMax(0);
  7. mqtt.setReconnectAttemptsMax(0);
  8. connection = mqtt.blockingConnection();
  9. connection.connect();
  10. }

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

  1. private MQTT createMQTTTcpConnection(String clientId, boolean clean) throws Exception {
  2. MQTT mqtt = new MQTT();
  3. mqtt.setConnectAttemptsMax(1);
  4. mqtt.setReconnectAttemptsMax(0);
  5. mqtt.setTracer(createTracer());
  6. mqtt.setVersion("3.1.1");
  7. if (clientId != null) {
  8. mqtt.setClientId(clientId);
  9. }
  10. mqtt.setCleanSession(clean);
  11. mqtt.setHost("localhost", port);
  12. return mqtt;
  13. }

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

  1. private BlockingConnection retrieveMQTTConnection(String host, String truststorePath, String truststorePass, String keystorePath, String keystorePass) throws Exception {
  2. MQTT mqtt = new MQTT();
  3. mqtt.setConnectAttemptsMax(1);
  4. mqtt.setReconnectAttemptsMax(0);
  5. mqtt.setHost(host);
  6. SSLContext sslContext = new SSLSupport()
  7. .setKeystorePath(keystorePath)
  8. .setKeystorePassword(keystorePass)
  9. .setTruststorePath(truststorePath)
  10. .setTruststorePassword(truststorePass)
  11. .createContext();
  12. mqtt.setSslContext(sslContext);
  13. BlockingConnection connection = mqtt.blockingConnection();
  14. connection.connect();
  15. return connection;
  16. }

相关文章