feat: 优化代码
parent
31e78c3c3c
commit
a8fff6ef70
|
@ -17,11 +17,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -10,21 +10,12 @@ import org.springframework.stereotype.Component;
|
|||
*/
|
||||
public interface AnalyzeEventContents {
|
||||
|
||||
/**
|
||||
* 故障
|
||||
*/
|
||||
//故障
|
||||
static final String BREAKDOWN = "breakdown";
|
||||
/**
|
||||
* 电子围栏
|
||||
*/
|
||||
//电子围栏
|
||||
static final String ELECTRONIC_FENCE = "electronic_fence";
|
||||
/**
|
||||
* 实时数据
|
||||
*/
|
||||
//实时数据
|
||||
static final String REAL_TIME_DATA = "real_time_data";
|
||||
|
||||
/**
|
||||
* 存储
|
||||
*/
|
||||
//存储
|
||||
static final String STORED_EVENT = "stored_event";
|
||||
}
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
*/
|
||||
@SpringBootApplication(scanBasePackages = "com.couplet")
|
||||
@EnableScheduling
|
||||
@EnableFeignClients(basePackages = "com.couplet.**")
|
||||
@EnableFeignClients(basePackages = "com.couplet")
|
||||
public class CoupletMsgApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CoupletMsgApplication.class);
|
||||
|
|
|
@ -36,7 +36,7 @@ import static java.lang.Thread.sleep;
|
|||
@Component
|
||||
@Slf4j
|
||||
public class ModelsKafkaMessage {
|
||||
private static final String TOPIC_NAME = "online";
|
||||
private static final String TOPIC_NAME = "xiaoYao";
|
||||
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
||||
|
||||
|
||||
|
@ -50,16 +50,13 @@ public class ModelsKafkaMessage {
|
|||
private AnalyzeEventCache analyzeEventCache;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//kafka消费者初始化
|
||||
@PostConstruct
|
||||
public void initKafkaConsumer() {
|
||||
Properties props = new Properties();
|
||||
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
|
||||
// props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group");
|
||||
props.put(ConsumerConfig.GROUP_ID_CONFIG, "ddd");
|
||||
props.put(ConsumerConfig.GROUP_ID_CONFIG, "xiaoYao");
|
||||
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
||||
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
||||
|
||||
|
@ -79,7 +76,8 @@ public class ModelsKafkaMessage {
|
|||
// @Scheduled(fixedDelay = 50)
|
||||
@PostConstruct
|
||||
public void consumerMessages() {
|
||||
executorService.execute(this::consumer);
|
||||
// executorService.execute(this::consumer);
|
||||
this.consumer();
|
||||
}
|
||||
|
||||
public void consumer() {
|
||||
|
|
|
@ -42,8 +42,12 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
log.info("实时数据事件开始.....");
|
||||
RealTimeDataRequest cacheObject = redisService.getCacheObject("vin:" + coupletMsgData.getVin());
|
||||
//判断是否有缓存数据
|
||||
if (RealTimeJudge.isJudge(coupletMsgData.getVin())) {
|
||||
log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin());
|
||||
if (redisService.hasKey("vin:query:" + cacheObject.getVin())){
|
||||
redisService.deleteObject("vin:query:" + cacheObject.getVin());
|
||||
}
|
||||
// if (RealTimeJudge.isJudge(coupletMsgData.getVin())) {
|
||||
if (coupletMsgData.getVin().equals(cacheObject.getVin())){
|
||||
// log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin());
|
||||
//判断数据是否一致,
|
||||
// if (RealTimeJudge.addRealTime(cacheObject)) {
|
||||
log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
@ -52,8 +50,3 @@ mybatis-plus:
|
|||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
# RabbitMQ配置
|
||||
mq:
|
||||
queueName: queue
|
||||
exchangeName: exchange
|
||||
routingKey: routingKey
|
||||
|
|
|
@ -16,11 +16,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -17,11 +17,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -76,7 +76,7 @@ public class MqttMonitor {
|
|||
|
||||
|
||||
//Kafka生产者配置
|
||||
private static final String TOPIC_NAME = "online";
|
||||
private static final String TOPIC_NAME = "xiaoYao";
|
||||
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
||||
|
||||
//线程池,用于异步处理消息到来时的业务逻辑
|
||||
|
|
Loading…
Reference in New Issue