package com.njzscloud.common.mqtt.config;

import com.njzscloud.common.mqtt.support.MqttCliWrapper;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty(value = "mqtt.enabled", havingValue = "true")
@EnableConfigurationProperties(MqttProperties.class)
public class MqttAutoConfiguration {

    @Bean(destroyMethod = "shutdown", name = "mqtt")
    public MqttCliWrapper mqtt(MqttProperties mqttProperties) {
        return new MqttCliWrapper(mqttProperties);
    }
}
