package com.zd.forward.serivce.mqtt;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.messaging.MessageHandler;
import org.springframework.stereotype.Component;

/**
 * @Author: zhoupan
 * @Date: 2021/11/15/19:01
 * @Description:
 */
@Component
@ConditionalOnProperty(prefix = "sys.mqtt" ,name = "inbound",havingValue = "true",matchIfMissing = true)
public class MqttOutListener {
    Logger logger = LoggerFactory.getLogger(MqttOutListener.class);

    @Bean
    @ServiceActivator(inputChannel = "mqttInputChannel")
    public MessageHandler handler() {

        return message -> logger.info("收到消息："+ message.getPayload());
    }

}
