package com.zd.forward.serivce.mqtt;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

/**
 * 消息发送者
 *
 * @author zpp
 */
@Component
@ConditionalOnProperty(prefix = "sys.mqtt" ,name = "outbound",havingValue = "true",matchIfMissing = true)
@MessagingGateway(defaultRequestChannel = "mqttOutboundChannel")
public interface MqttProducer {

    /**
     * 发送信息
     * @param data
     */
    void sendToMqtt(String data);

    /**
     * 指定主题发送信息
     * @param topic
     * @param payload
     */
    void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, String payload);

    /**
     * 指定主题和qos发送信息
     * @param topic
     * @param qos
     * @param payload
     */
    void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, @Header(MqttHeaders.QOS) int qos, String payload);
}
