|
|
@@ -1,79 +0,0 @@
|
|
|
-package com.yunfeiyun.agmp.iots.mq.bussiness;
|
|
|
-
|
|
|
-
|
|
|
-import com.yunfeiyun.agmp.iot.common.constant.mq.IotMqExchange;
|
|
|
-import com.yunfeiyun.agmp.iot.common.constant.mq.IotMqQueue;
|
|
|
-import com.yunfeiyun.agmp.iots.mq.listener.IotsChannelGlobalAwareMessageListener;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.amqp.core.*;
|
|
|
-import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
|
|
-import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
-import org.springframework.context.annotation.Configuration;
|
|
|
-/**/
|
|
|
-import javax.annotation.PostConstruct;
|
|
|
-
|
|
|
-/**
|
|
|
- * TOS 的 MQ配置
|
|
|
- * 1. 链接信息
|
|
|
- * 2. queue 定义
|
|
|
- * 3. exchange 定义
|
|
|
- * 4. routing key 定义
|
|
|
- * 5. 链接工厂定义
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@Configuration
|
|
|
-@ConditionalOnBean(name = "iotMqBusConfig")
|
|
|
-public class IotMqBusConfig {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- @Qualifier("iotAmqpAdmin")
|
|
|
- private AmqpAdmin iotAmqpAdmin;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @PostConstruct
|
|
|
- public void init() {
|
|
|
- log.info("加载Tos 全局租户通道 Mq");
|
|
|
- iotAmqpAdmin.declareExchange(iotmToIotsGlobalExchange());
|
|
|
- iotAmqpAdmin.declareQueue(topicTaskQueue());
|
|
|
- iotAmqpAdmin.declareBinding(topicTaskBinding());
|
|
|
- }
|
|
|
-
|
|
|
- public FanoutExchange iotmToIotsGlobalExchange() {
|
|
|
- return new FanoutExchange(IotMqExchange.IOTM_TO_IOTS_EXCHANGE);
|
|
|
- }
|
|
|
-
|
|
|
- public Queue topicTaskQueue() {
|
|
|
- return QueueBuilder.durable(IotMqQueue.IOTM_TO_IOTS_CMD_QUEUE).build();
|
|
|
- }
|
|
|
- public Binding topicTaskBinding() {
|
|
|
- return BindingBuilder.bind(topicTaskQueue()).to(iotmToIotsGlobalExchange());
|
|
|
- }
|
|
|
-
|
|
|
- // ########################################## 接受tos消息 全部租户通道结束##########################################
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 配置接受所有租户都要处理的监听器,用户消息回执
|
|
|
- *
|
|
|
- * @param connectionFactory
|
|
|
- * @param lobleAwareMessageListener
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Bean("iotGlobleSimpleMessageListenerContainer")
|
|
|
- public SimpleMessageListenerContainer iotsGlobleSimpleMessageListenerContainer(
|
|
|
- @Qualifier("iotConnectionFactory") CachingConnectionFactory connectionFactory,
|
|
|
- IotsChannelGlobalAwareMessageListener lobleAwareMessageListener) {
|
|
|
- SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
|
|
|
- container.setQueues(topicTaskQueue());
|
|
|
- container.setMessageListener(lobleAwareMessageListener);
|
|
|
- container.setAmqpAdmin(iotAmqpAdmin);
|
|
|
- // 设置确认模式为手动确认
|
|
|
- container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
|
|
|
- return container;
|
|
|
- }
|
|
|
-}
|