rain
2024-08-21 2db1aa88e8ab53096a936163d686b90d8e056a99
src/main/java/com/dji/sample/component/mqtt/config/MqttInboundConfiguration.java
@@ -1,6 +1,7 @@
package com.dji.sample.component.mqtt.config;
import com.dji.sample.component.mqtt.model.ChannelName;
import com.dji.sample.component.mqtt.model.MqttClientOptions;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@@ -29,9 +30,6 @@
public class MqttInboundConfiguration {
    @Autowired
    private MqttConfiguration mqttConfiguration;
    @Autowired
    private MqttPahoClientFactory mqttClientFactory;
    @Resource(name = ChannelName.INBOUND)
@@ -43,9 +41,10 @@
     */
    @Bean(name = "adapter")
    public MessageProducerSupport mqttInbound() {
        MqttClientOptions options = MqttConfiguration.getBasicClientOptions();
        MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter(
                mqttConfiguration.getClientId() + "_consumer_" + System.currentTimeMillis(),
                mqttClientFactory, mqttConfiguration.getInboundTopic().split(","));
                options.getClientId() + "_consumer_" + System.currentTimeMillis(),
                mqttClientFactory, options.getInboundTopic().split(","));
        DefaultPahoMessageConverter converter = new DefaultPahoMessageConverter();
        // use byte types uniformly
        converter.setPayloadAsBytes(true);
@@ -57,6 +56,7 @@
    /**
     * Define a default channel to handle messages that have no effect.
     * 定义默认通道处理无效消息
     * @return
     */
    @Bean