本文整理汇总了Java中io.moquette.server.Server.startServer方法的典型用法代码示例。如果您正苦于以下问题:Java Server.startServer方法的具体用法?Java Server.startServer怎么用?Java Server.startServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.moquette.server.Server
的用法示例。
在下文中一共展示了Server.startServer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startBroker
import io.moquette.server.Server; //导入方法依赖的package包/类
private Server startBroker(Server server, IConfig memoryConfig) {
try {
server.startServer(memoryConfig);
return server;
} catch (final IOException e) {
throw propagate(e);
}
}
示例2: start
import io.moquette.server.Server; //导入方法依赖的package包/类
@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
public synchronized void start() throws Exception {
long time = log(LOG, "start");
File mqttServerDirectory = new File(ABS_DIR_MQTT);
FileUtils.deleteDirectory(mqttServerDirectory);
mqttServerDirectory.mkdirs();
mqttServer = new Server();
Properties mqttServerProperties = new Properties();
mqttServerProperties.put(PERSISTENT_STORE_PROPERTY_NAME, ABS_DIR_MQTT + File.separatorChar + MQTT_BROKER_STORE_NAME);
mqttServerProperties.put(PORT_PROPERTY_NAME, "" + MQTT_BROKER_PORT);
mqttServer.startServer(new MemoryConfig(mqttServerProperties));
log(LOG, "start", time);
}
示例3: main
import io.moquette.server.Server; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException, IOException {
IResourceLoader classpathLoader = new ClasspathResourceLoader();
final IConfig classPathConfig = new ResourceLoaderConfig(classpathLoader);
final Server mqttBroker = new Server();
List<? extends InterceptHandler> userHandlers = Collections.singletonList(new PublisherListener());
mqttBroker.startServer(classPathConfig, userHandlers);
System.out.println("Broker started press [CTRL+C] to stop");
//Bind a shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
System.out.println("Stopping broker");
mqttBroker.stopServer();
System.out.println("Broker stopped");
}));
Thread.sleep(20000);
System.out.println("Before self publish");
MqttPublishMessage message = MqttMessageBuilders.publish()
.topicName("/exit")
.retained(true)
// qos(MqttQoS.AT_MOST_ONCE);
// qQos(MqttQoS.AT_LEAST_ONCE);
.qos(MqttQoS.EXACTLY_ONCE)
.payload(Unpooled.copiedBuffer("Hello World!!".getBytes()))
.build();
mqttBroker.internalPublish(message, "INTRLPUB");
System.out.println("After self publish");
}
示例4: onStart
import io.moquette.server.Server; //导入方法依赖的package包/类
@Override
protected void onStart() throws PluginStartupException {
// load topics from manifest file
loadTopics();
mqttBroker = new Server();
Properties props = new Properties();
// get properties from manifest file
props.setProperty(BrokerConstants.PORT_PROPERTY_NAME, Integer.toString(BROKER_PORT));
props.setProperty(BrokerConstants.HOST_PROPERTY_NAME, BROKER_HOST);
props.setProperty(BrokerConstants.PASSWORD_FILE_PROPERTY_NAME, Info.PATHS.PATH_DEVICES_FOLDER + "/mqtt-broker/config/password_file.conf");
props.setProperty(BrokerConstants.PERSISTENT_STORE_PROPERTY_NAME, Info.PATHS.PATH_DEVICES_FOLDER + "/mqtt-broker/config/moquette_store.mapdb");
config = new MemoryConfig(props);
userHandlers = asList(new PublisherListener());
try {
mqttBroker.startServer(config, userHandlers);
} catch (IOException ex) {
throw new PluginStartupException("Plugin can't start for an IOException.", ex);
}
setDescription("MQTT broker listening to " + config.getProperty(BrokerConstants.HOST_PROPERTY_NAME) + ":" + config.getProperty(BrokerConstants.PORT_PROPERTY_NAME));
LOG.info("MQTT broker plugin started");
}
示例5: startServer
import io.moquette.server.Server; //导入方法依赖的package包/类
protected void startServer() throws IOException {
m_server = new Server();
m_server.startServer();
}