本文整理汇总了Java中org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory类的典型用法代码示例。如果您正苦于以下问题:Java DefaultMqttPahoClientFactory类的具体用法?Java DefaultMqttPahoClientFactory怎么用?Java DefaultMqttPahoClientFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultMqttPahoClientFactory类属于org.springframework.integration.mqtt.core包,在下文中一共展示了DefaultMqttPahoClientFactory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mqttClientFactory
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory; //导入依赖的package包/类
@Bean
public MqttPahoClientFactory mqttClientFactory() {
DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
factory.setServerURIs(mqttProperties.getUrl());
factory.setUserName(mqttProperties.getUsername());
factory.setPassword(mqttProperties.getPassword());
factory.setCleanSession(mqttProperties.isCleanSession());
factory.setConnectionTimeout(mqttProperties.getConnectionTimeout());
factory.setKeepAliveInterval(mqttProperties.getKeepAliveInterval());
if (ObjectUtils.nullSafeEquals(mqttProperties.getPersistence(), "file")) {
factory.setPersistence(new MqttDefaultFilePersistence(mqttProperties.getPersistenceDirectory()));
}
else if (ObjectUtils.nullSafeEquals(mqttProperties.getPersistence(), "memory")) {
factory.setPersistence(new MemoryPersistence());
}
return factory;
}
示例2: mqttClientFactory
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory; //导入依赖的package包/类
@Bean
public MqttPahoClientFactory mqttClientFactory() {
AuthConfiguration.AdminUser defaultUser = raptorConfiguration.getAuth().getServiceUser();
if (defaultUser == null) {
throw new RuntimeException("Missing service user. Review raptor.yml configuration file under auth.users section");
}
DispatcherConfiguration dispatcherConfig = raptorConfiguration.getDispatcher();
DefaultMqttPahoClientFactory f = new DefaultMqttPahoClientFactory();
log.debug("Using local broker user {}", defaultUser.getUsername());
f.setUserName(defaultUser.getUsername());
f.setPassword(defaultUser.getPassword());
f.setServerURIs(dispatcherConfig.getUri());
f.setCleanSession(true);
f.setPersistence(new MemoryPersistence());
return f;
}
示例3: obtainResource
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory; //导入依赖的package包/类
@Override
protected void obtainResource() throws Exception {
DefaultMqttPahoClientFactory connectionFactory = new DefaultMqttPahoClientFactory();
connectionFactory.setServerURIs("tcp://localhost:1883");
connectionFactory.setUserName("guest");
connectionFactory.setPassword("guest");
connectionFactory.setConnectionTimeout(1);
resource = connectionFactory.getClientInstance("tcp://localhost:1883", "scdf-test-client");
resource.connect(connectionFactory.getConnectionOptions());
}
示例4: clientFactory
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory; //导入依赖的package包/类
@Bean
public DefaultMqttPahoClientFactory clientFactory() {
// could define username and password for broker connection here
return new DefaultMqttPahoClientFactory();
}