| | |
| | | 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; |
| | |
| | | public class MqttInboundConfiguration { |
| | | |
| | | @Autowired |
| | | private MqttConfiguration mqttConfiguration; |
| | | |
| | | @Autowired |
| | | private MqttPahoClientFactory mqttClientFactory; |
| | | |
| | | @Resource(name = ChannelName.INBOUND) |
| | |
| | | */ |
| | | @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); |