12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package com.xy.consumer.disconnect;
- import com.xy.configuration.MqttConfigUtils;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.integration.annotation.IntegrationComponentScan;
- import org.springframework.integration.annotation.ServiceActivator;
- import org.springframework.integration.channel.DirectChannel;
- import org.springframework.integration.core.MessageProducer;
- import org.springframework.messaging.MessageChannel;
- import org.springframework.messaging.MessageHandler;
- @Configuration
- @IntegrationComponentScan
- public class DisconnectedMqttConfiguration {
- /**
- * topic
- */
- public final static String TOPIC = "disConnectedNotify";
- /**
- * 入站通道名(消费者)订阅的bean名称
- */
- public static final String CHANNEL_NAME_IN = TOPIC + "MqttInboundChannel";
- /*******************************消费者*******************************************/
- /**
- * MQTT信息通道(消费者)
- */
- @Bean(name = CHANNEL_NAME_IN)
- public MessageChannel mqttInboundChannel() {
- return new DirectChannel();
- }
- /**
- * MQTT消息订阅绑定(消费者)
- */
- @Bean(name = TOPIC + "Inbound")
- public MessageProducer inbound() {
- return MqttConfigUtils.inbound(TOPIC, mqttInboundChannel());
- }
- /**
- * MQTT消息处理器(消费者)
- */
- @Bean(name = TOPIC + "Handler")
- @ServiceActivator(inputChannel = CHANNEL_NAME_IN)
- public MessageHandler handler() {
- return MqttConfigUtils.handler();
- }
- }
|