Commit 831970233c63cd50f056b330f0e675102d2dd9c3
1 parent
7ab61b6d
【代码优化】IoT: 数据桥梁的执行器根据引入的消息队列动态加载
Showing
4 changed files
with
19 additions
and
0 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/action/databridge/IotKafkaMQDataBridgeExecute.java
| ... | ... | @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.iot.mq.message.IotDeviceMessage; |
| 6 | 6 | import lombok.extern.slf4j.Slf4j; |
| 7 | 7 | import org.apache.kafka.clients.producer.ProducerConfig; |
| 8 | 8 | import org.apache.kafka.common.serialization.StringSerializer; |
| 9 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | |
| 9 | 10 | import org.springframework.kafka.core.DefaultKafkaProducerFactory; |
| 10 | 11 | import org.springframework.kafka.core.KafkaTemplate; |
| 11 | 12 | import org.springframework.stereotype.Component; |
| ... | ... | @@ -21,6 +22,7 @@ import java.util.concurrent.TimeUnit; |
| 21 | 22 | * |
| 22 | 23 | * @author HUIHUI |
| 23 | 24 | */ |
| 25 | +@ConditionalOnClass(KafkaTemplate.class) | |
| 24 | 26 | @Component |
| 25 | 27 | @Slf4j |
| 26 | 28 | public class IotKafkaMQDataBridgeExecute extends | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/action/databridge/IotRabbitMQDataBridgeExecute.java
| ... | ... | @@ -7,6 +7,7 @@ import com.rabbitmq.client.Channel; |
| 7 | 7 | import com.rabbitmq.client.Connection; |
| 8 | 8 | import com.rabbitmq.client.ConnectionFactory; |
| 9 | 9 | import lombok.extern.slf4j.Slf4j; |
| 10 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | |
| 10 | 11 | import org.springframework.stereotype.Component; |
| 11 | 12 | |
| 12 | 13 | import java.nio.charset.StandardCharsets; |
| ... | ... | @@ -17,6 +18,7 @@ import java.time.LocalDateTime; |
| 17 | 18 | * |
| 18 | 19 | * @author HUIHUI |
| 19 | 20 | */ |
| 21 | +@ConditionalOnClass(Channel.class) | |
| 20 | 22 | @Component |
| 21 | 23 | @Slf4j |
| 22 | 24 | public class IotRabbitMQDataBridgeExecute extends | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/action/databridge/IotRocketMQDataBridgeExecute.java
| ... | ... | @@ -9,6 +9,7 @@ import org.apache.rocketmq.client.producer.SendResult; |
| 9 | 9 | import org.apache.rocketmq.client.producer.SendStatus; |
| 10 | 10 | import org.apache.rocketmq.common.message.Message; |
| 11 | 11 | import org.apache.rocketmq.remoting.common.RemotingHelper; |
| 12 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | |
| 12 | 13 | import org.springframework.stereotype.Component; |
| 13 | 14 | |
| 14 | 15 | import java.time.LocalDateTime; |
| ... | ... | @@ -18,6 +19,7 @@ import java.time.LocalDateTime; |
| 18 | 19 | * |
| 19 | 20 | * @author HUIHUI |
| 20 | 21 | */ |
| 22 | +@ConditionalOnClass(DefaultMQProducer.class) | |
| 21 | 23 | @Component |
| 22 | 24 | @Slf4j |
| 23 | 25 | public class IotRocketMQDataBridgeExecute extends | ... | ... |
yudao-server/pom.xml
| ... | ... | @@ -114,6 +114,19 @@ |
| 114 | 114 | <artifactId>yudao-module-iot-biz</artifactId> |
| 115 | 115 | <version>${revision}</version> |
| 116 | 116 | </dependency> |
| 117 | + <!-- IoT 数据桥梁的执行器所需消息队列。如果您只需要使用 rocketmq 那么则注释掉其它消息队列即可 --> | |
| 118 | + <dependency> | |
| 119 | + <groupId>org.apache.rocketmq</groupId> | |
| 120 | + <artifactId>rocketmq-spring-boot-starter</artifactId> | |
| 121 | + </dependency> | |
| 122 | + <dependency> | |
| 123 | + <groupId>org.springframework.kafka</groupId> | |
| 124 | + <artifactId>spring-kafka</artifactId> | |
| 125 | + </dependency> | |
| 126 | + <dependency> | |
| 127 | + <groupId>org.springframework.boot</groupId> | |
| 128 | + <artifactId>spring-boot-starter-amqp</artifactId> | |
| 129 | + </dependency> | |
| 117 | 130 | |
| 118 | 131 | <!-- spring boot 配置所需依赖 --> |
| 119 | 132 | <dependency> | ... | ... |