本文整理汇总了Java中org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory.setUserName方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMqttPahoClientFactory.setUserName方法的具体用法?Java DefaultMqttPahoClientFactory.setUserName怎么用?Java DefaultMqttPahoClientFactory.setUserName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory
的用法示例。
在下文中一共展示了DefaultMqttPahoClientFactory.setUserName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}