Compare commits
2 Commits
b9529234e9
...
ff3f1e8ac2
Author | SHA1 | Date |
---|---|---|
|
ff3f1e8ac2 | |
|
147dbe2c99 |
|
@ -24,22 +24,11 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-core</artifactId>
|
<artifactId>cloud-common-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--swagger3maven依赖-->
|
|
||||||
|
<!--swagger3依赖-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger.core.v3</groupId>
|
<groupId>io.swagger.core.v3</groupId>
|
||||||
<artifactId>swagger-annotations-jakarta</artifactId>
|
<artifactId>swagger-annotations-jakarta</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--mqttv3依赖-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.paho</groupId>
|
|
||||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
|
||||||
<version>1.2.2</version>
|
|
||||||
</dependency>
|
|
||||||
<!--mqtt依赖-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.integration</groupId>
|
|
||||||
<artifactId>spring-integration-mqtt</artifactId>
|
|
||||||
<version>6.2.5</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -83,41 +83,13 @@
|
||||||
<artifactId>cloud-common-api-doc</artifactId>
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 阿里云创建ecs实例 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aliyun</groupId>
|
|
||||||
<artifactId>ecs20140526</artifactId>
|
|
||||||
<version>5.1.8</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aliyun</groupId>
|
|
||||||
<artifactId>tea-openapi</artifactId>
|
|
||||||
<version>0.3.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aliyun</groupId>
|
|
||||||
<artifactId>tea-console</artifactId>
|
|
||||||
<version>0.0.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aliyun</groupId>
|
|
||||||
<artifactId>tea-util</artifactId>
|
|
||||||
<version>0.2.21</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aliyun</groupId>
|
|
||||||
<artifactId>cloudapi20160714</artifactId>
|
|
||||||
<version>3.10.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 企业业务平台 - 公共依赖 -->
|
<!-- 企业业务平台 - 公共依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-modules-enterprise-common</artifactId>
|
<artifactId>cloud-modules-enterprise-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- MyBatisPlus - 依赖包 -->
|
<!-- MyBatisPlusJoin 依赖包 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.yulichang</groupId>
|
<groupId>com.github.yulichang</groupId>
|
||||||
<artifactId>mybatis-plus-join</artifactId>
|
<artifactId>mybatis-plus-join</artifactId>
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.muyu.event.process.consumer;
|
||||||
|
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
|
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
|
||||||
import com.muyu.common.core.constant.KafkaConstants;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.kafka.clients.consumer.ConsumerRecords;
|
import org.apache.kafka.clients.consumer.ConsumerRecords;
|
||||||
|
@ -19,7 +18,7 @@ import java.util.Collection;
|
||||||
* @Description 测试消费者
|
* @Description 测试消费者
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
//@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class TestConsumer implements InitializingBean {
|
public class TestConsumer implements InitializingBean {
|
||||||
|
|
||||||
|
@ -28,12 +27,18 @@ public class TestConsumer implements InitializingBean {
|
||||||
*/
|
*/
|
||||||
private final KafkaConsumer<String, String> kafkaConsumer;
|
private final KafkaConsumer<String, String> kafkaConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kafka主题名称
|
||||||
|
*/
|
||||||
|
private static final String topicName = "test-topic";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
log.info("启动线程监听Topic: {}", KafkaConstants.MESSAGE_PARSING);
|
log.info("启动线程监听Topic: {}", topicName);
|
||||||
ThreadUtil.sleep(1000);
|
ThreadUtil.sleep(1000);
|
||||||
Collection<String> topics = Lists.newArrayList(KafkaConstants.MESSAGE_PARSING);
|
Collection<String> topics = Lists.newArrayList(topicName);
|
||||||
kafkaConsumer.subscribe(topics);
|
kafkaConsumer.subscribe(topics);
|
||||||
while (true) {
|
while (true) {
|
||||||
ConsumerRecords<String, String> consumerRecords = kafkaConsumer.poll(Duration.ofMillis(1000));
|
ConsumerRecords<String, String> consumerRecords = kafkaConsumer.poll(Duration.ofMillis(1000));
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class VehicleConsumer implements ApplicationRunner, ApplicationListener<C
|
||||||
List<String> topics = Collections.singletonList(KafkaConstants.MESSAGE_PARSING);
|
List<String> topics = Collections.singletonList(KafkaConstants.MESSAGE_PARSING);
|
||||||
kafkaConsumer.subscribe(topics);
|
kafkaConsumer.subscribe(topics);
|
||||||
while (true) {
|
while (true) {
|
||||||
ConsumerRecords<String, String> consumerRecords = kafkaConsumer.poll(Duration.ofMillis(100));
|
ConsumerRecords<String, String> consumerRecords = kafkaConsumer.poll(Duration.ofMillis(200));
|
||||||
consumerRecords.forEach(consumerRecord -> executorService.submit(() -> handleRecord(consumerRecord)));
|
consumerRecords.forEach(consumerRecord -> executorService.submit(() -> handleRecord(consumerRecord)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
pom.xml
32
pom.xml
|
@ -48,9 +48,9 @@
|
||||||
<tea-console.version>0.0.1</tea-console.version>
|
<tea-console.version>0.0.1</tea-console.version>
|
||||||
<tea-util.version>0.2.21</tea-util.version>
|
<tea-util.version>0.2.21</tea-util.version>
|
||||||
<cloudapi20160714.version>3.10.1</cloudapi20160714.version>
|
<cloudapi20160714.version>3.10.1</cloudapi20160714.version>
|
||||||
|
|
||||||
<kafka.clients.verison>3.0.0</kafka.clients.verison>
|
<kafka.clients.verison>3.0.0</kafka.clients.verison>
|
||||||
<iotdb-session.verison>1.3.1</iotdb-session.verison>
|
<iotdb.session.verison>1.3.1</iotdb.session.verison>
|
||||||
|
<mybatis.plus.join.version>1.4.13</mybatis.plus.join.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
|
@ -198,6 +198,27 @@
|
||||||
<version>${swagger.an.jakarta.verison}</version>
|
<version>${swagger.an.jakarta.verison}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MyBatisPlusJoin 依赖包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.yulichang</groupId>
|
||||||
|
<artifactId>mybatis-plus-join</artifactId>
|
||||||
|
<version>1.4.13</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- kafka客户端 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.kafka</groupId>
|
||||||
|
<artifactId>kafka-clients</artifactId>
|
||||||
|
<version>${kafka.clients.verison}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- IotDB会话 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.iotdb</groupId>
|
||||||
|
<artifactId>iotdb-session</artifactId>
|
||||||
|
<version>${iotdb.session.verison}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 核心模块 -->
|
<!-- 核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
|
@ -289,6 +310,13 @@
|
||||||
<version>${muyu.version}</version>
|
<version>${muyu.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- kafka模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-kafka</artifactId>
|
||||||
|
<version>${muyu.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 企业业务平台 - 公告模块 -->
|
<!-- 企业业务平台 - 公告模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
|
|
Loading…
Reference in New Issue