优化判断语句
parent
54a091e3b6
commit
9bb5cf3435
|
@ -81,12 +81,12 @@
|
||||||
<artifactId>couplet-common-swagger</artifactId>
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- mqttx依赖 -->
|
<!-- <!– mqttx依赖 –>-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.eclipse.paho</groupId>
|
<!-- <groupId>org.eclipse.paho</groupId>-->
|
||||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
<!-- <artifactId>org.eclipse.paho.client.mqttv3</artifactId>-->
|
||||||
<version>1.2.5</version>
|
<!-- <version>1.2.5</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<!-- 事件核心配置 -->
|
<!-- 事件核心配置 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.couplet</groupId>
|
<groupId>com.couplet</groupId>
|
||||||
|
@ -94,20 +94,28 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.springframework.kafka</groupId>
|
<groupId>org.springframework.kafka</groupId>
|
||||||
<artifactId>spring-kafka</artifactId>
|
<artifactId>spring-kafka</artifactId>
|
||||||
|
</dependency>-->
|
||||||
|
|
||||||
|
<!-- Kafka依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.kafka</groupId>
|
||||||
|
<artifactId>kafka-clients</artifactId>
|
||||||
|
<version>2.8.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.couplet</groupId>
|
<groupId>com.couplet</groupId>
|
||||||
<artifactId>couplet-common-business</artifactId>
|
<artifactId>couplet-common-business</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- RabbitMQ依赖-->
|
<!-- <!– RabbitMQ依赖–>-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.springframework.boot</groupId>
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
<!-- <artifactId>spring-boot-starter-amqp</artifactId>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.couplet.analyze.msg;
|
package com.couplet.analyze.msg;
|
||||||
|
|
||||||
|
import com.couplet.analyze.msg.model.ModelsKafkaMessage;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
@ -15,8 +17,13 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableFeignClients(basePackages = "com.couplet.**")
|
@EnableFeignClients(basePackages = "com.couplet.**")
|
||||||
public class CoupletMsgApplication {
|
public class CoupletMsgApplication {
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(CoupletMsgApplication.class);
|
SpringApplication.run(CoupletMsgApplication.class);
|
||||||
System.out.println("解析系统启动成功");
|
System.out.println("解析系统启动成功");
|
||||||
|
// new ModelsKafkaMessage().initKafkaConsumer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.couplet.analyze.msg.model;
|
package com.couplet.analyze.msg.model;
|
||||||
|
|
||||||
|
|
||||||
import com.couplet.analyze.common.event.AnalyzeEventCache;
|
import com.couplet.analyze.common.event.AnalyzeEventCache;
|
||||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||||
import com.couplet.analyze.msg.service.IncidentService;
|
import com.couplet.analyze.msg.service.IncidentService;
|
||||||
|
@ -10,7 +11,6 @@ import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||||
import org.apache.kafka.clients.consumer.ConsumerRecords;
|
import org.apache.kafka.clients.consumer.ConsumerRecords;
|
||||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
@ -26,7 +26,6 @@ import static com.couplet.analyze.msg.utils.MsgUtils.hexToString;
|
||||||
import static com.couplet.analyze.msg.utils.MsgUtils.sendMsg;
|
import static com.couplet.analyze.msg.utils.MsgUtils.sendMsg;
|
||||||
import static java.lang.Thread.sleep;
|
import static java.lang.Thread.sleep;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DongXiaoDong
|
* @author DongXiaoDong
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
|
@ -36,7 +35,7 @@ import static java.lang.Thread.sleep;
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ModelsKafkaMessage {
|
public class ModelsKafkaMessage {
|
||||||
private static final String TOPIC_NAME = "online";
|
private static final String TOPIC_NAME = "dong";
|
||||||
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +88,7 @@ public class ModelsKafkaMessage {
|
||||||
while (true) {
|
while (true) {
|
||||||
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
|
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
|
||||||
records.forEach(record -> {
|
records.forEach(record -> {
|
||||||
System.out.println("接收到的数据:" + record.value());
|
log.info("接收到的数据:" + record.value());
|
||||||
String str = hexToString(record.value());
|
String str = hexToString(record.value());
|
||||||
List<CoupletMsgData> coupletMsgDataList = sendMsg(str);
|
List<CoupletMsgData> coupletMsgDataList = sendMsg(str);
|
||||||
for (CoupletMsgData msgData : coupletMsgDataList) {
|
for (CoupletMsgData msgData : coupletMsgDataList) {
|
||||||
|
|
|
@ -50,9 +50,3 @@ logging:
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
configuration:
|
configuration:
|
||||||
map-underscore-to-camel-case: true
|
map-underscore-to-camel-case: true
|
||||||
|
|
||||||
# RabbitMQ配置
|
|
||||||
mq:
|
|
||||||
queueName: queue
|
|
||||||
exchangeName: exchange
|
|
||||||
routingKey: routingKey
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class MqttMonitor {
|
||||||
|
|
||||||
|
|
||||||
//Kafka生产者配置
|
//Kafka生产者配置
|
||||||
private static final String TOPIC_NAME = "online";
|
private static final String TOPIC_NAME = "dong";
|
||||||
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
||||||
|
|
||||||
//线程池,用于异步处理消息到来时的业务逻辑
|
//线程池,用于异步处理消息到来时的业务逻辑
|
||||||
|
|
|
@ -34,11 +34,11 @@ logging:
|
||||||
# 订阅端配置
|
# 订阅端配置
|
||||||
mqtt:
|
mqtt:
|
||||||
server:
|
server:
|
||||||
broker: tcp://115.159.47.13:1883
|
# broker: tcp://115.159.47.13:1883
|
||||||
# broker: mqtt://115.159.47.13:1883
|
broker: tcp://8.130.181.16:1883
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
clientId: mq
|
clientId: aaa
|
||||||
qos: 0
|
qos: 0
|
||||||
topic: dxd
|
topic: dxd
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue