org.springframework.integration.mqtt.core.MqttPahoClientFactory Java Examples

The following examples show how to use org.springframework.integration.mqtt.core.MqttPahoClientFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MqttConfiguration.java    From mqtt with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: MqttMessageClient.java    From mqtt-spring-boot with MIT License 4 votes vote down vote up
public MqttMessageClient(String clientId, MqttPahoClientFactory clientFactory) {
    super(clientId, clientFactory);
}
 
Example #3
Source File: MqttConfig.java    From iot-dc3 with Apache License 2.0 4 votes vote down vote up
@Bean
public MqttPahoClientFactory mqttClientFactory() {
    DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
    factory.setConnectionOptions(getMqttConnectOptions());
    return factory;
}