当前位置: 首页>>代码示例>>Java>>正文


Java DefaultMqttPahoClientFactory类代码示例

本文整理汇总了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;
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:mqtt,代码行数:18,代码来源:MqttConfiguration.java

示例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;
}
 
开发者ID:raptorbox,项目名称:raptor,代码行数:24,代码来源:MqttConfiguration.java

示例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());
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:mqtt,代码行数:11,代码来源:MqttTestSupport.java

示例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();
}
 
开发者ID:andypiper,项目名称:spring-int-mqtt,代码行数:6,代码来源:Application.java


注:本文中的org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。