本文整理了Java中org.fusesource.mqtt.client.MQTT.futureConnection()
方法的一些代码示例,展示了MQTT.futureConnection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MQTT.futureConnection()
方法的具体详情如下:
包路径:org.fusesource.mqtt.client.MQTT
类名称:MQTT
方法名:futureConnection
暂无
代码示例来源:origin: fusesource/mqtt-client
public BlockingConnection blockingConnection() {
return new BlockingConnection(futureConnection());
}
代码示例来源:origin: dempeZheng/forest-chat
public FutureConnection connect() throws Exception {
this.connection = mqtt.futureConnection();
Future<Void> connect = connection.connect();
return connection;
}
代码示例来源:origin: org.fusesource.mqtt-client/mqtt-client
public BlockingConnection blockingConnection() {
return new BlockingConnection(futureConnection());
}
代码示例来源:origin: tuanhiep/mqtt-jmeter
private FutureConnection createConnection(String host,String clientId) {
try {
MQTT client = new MQTT();
client.setHost(host);
client.setClientId(clientId);
return client.futureConnection();
} catch (URISyntaxException e) {
getLogger().error(e.getMessage());
return null;
}
}
private FutureConnection createConnection(String host,String clientId,String user, String password) {
代码示例来源:origin: sitewhere/sitewhere
/**
* Get a {@link FutureConnection} to the MQTT broker.
*
* @return
* @throws SiteWhereException
*/
public FutureConnection getConnection() throws SiteWhereException {
FutureConnection connection = mqtt.futureConnection();
try {
Future<Void> future = connection.connect();
future.await(DEFAULT_CONNECT_TIMEOUT_SECS, TimeUnit.SECONDS);
return connection;
} catch (Exception e) {
throw new SiteWhereException("Unable to connect to MQTT broker.", e);
}
}
代码示例来源:origin: com.sitewhere/sitewhere-core
/**
* Get a {@link FutureConnection} to the MQTT broker.
*
* @return
* @throws SiteWhereException
*/
public FutureConnection getConnection() throws SiteWhereException {
FutureConnection connection = mqtt.futureConnection();
try {
Future<Void> future = connection.connect();
future.await(DEFAULT_CONNECT_TIMEOUT_SECS, TimeUnit.SECONDS);
return connection;
} catch (Exception e) {
throw new SiteWhereException("Unable to connect to MQTT broker.", e);
}
}
代码示例来源:origin: tuanhiep/mqtt-jmeter
private FutureConnection createConnection(String host,String clientId,String user, String password) {
try {
MQTT client = new MQTT();
client.setHost(host);
client.setUserName(user);
client.setPassword(password);
client.setClientId(clientId);
return client.futureConnection();
} catch (URISyntaxException e) {
getLogger().error(e.getMessage());
return null;
}
}
代码示例来源:origin: com.sitewhere/sitewhere-core
@Override
public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException {
if ((topic == null) && ((multicaster == null) && (routeBuilder == null))) {
throw new SiteWhereException("No topic specified and no multicaster or route builder configured.");
}
// Required for filters.
super.start(monitor);
// Start multicaster if configured.
if (multicaster != null) {
startNestedComponent(multicaster, monitor, true);
}
// Start route builder if configured.
if (routeBuilder != null) {
startNestedComponent(routeBuilder, monitor, true);
}
// Use common MQTT configuration setup.
this.queue = Dispatch.createQueue(getComponentId());
this.mqtt = MqttLifecycleComponent.configure(this, queue);
LOGGER.info("Connecting to MQTT broker at '" + getHostname() + ":" + getPort() + "'...");
connection = mqtt.futureConnection();
try {
Future<Void> future = connection.connect();
future.await(MqttLifecycleComponent.DEFAULT_CONNECT_TIMEOUT_SECS, TimeUnit.SECONDS);
} catch (Exception e) {
throw new SiteWhereException("Unable to connect to MQTT broker.", e);
}
LOGGER.info("Connected to MQTT broker.");
}
代码示例来源:origin: sitewhere/sitewhere
@Override
public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException {
if ((topic == null) && ((multicaster == null) && (routeBuilder == null))) {
throw new SiteWhereException("No topic specified and no multicaster or route builder configured.");
}
// Required for filters.
super.start(monitor);
// Start multicaster if configured.
if (multicaster != null) {
startNestedComponent(multicaster, monitor, true);
}
// Start route builder if configured.
if (routeBuilder != null) {
startNestedComponent(routeBuilder, monitor, true);
}
// Use common MQTT configuration setup.
this.queue = Dispatch.createQueue(getComponentId().toString());
this.mqtt = MqttLifecycleComponent.configure(this, queue);
getLogger().info("Connecting to MQTT broker at '" + getHostname() + ":" + getPort() + "'...");
connection = mqtt.futureConnection();
try {
Future<Void> future = connection.connect();
future.await(MqttLifecycleComponent.DEFAULT_CONNECT_TIMEOUT_SECS, TimeUnit.SECONDS);
} catch (Exception e) {
throw new SiteWhereException("Unable to connect to MQTT broker.", e);
}
getLogger().info("Connected to MQTT broker.");
}
内容来源于网络,如有侵权,请联系作者删除!