parent
4ccc21132c
commit
7ca3d4dede
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -389,4 +389,9 @@ public class RedisService {
|
|||
public Collection<String> keys(final String pattern) {
|
||||
return redisTemplate.keys(pattern);
|
||||
}
|
||||
|
||||
public void deleteCacheSet(String s) {
|
||||
SetOperations setOperations = redisTemplate.opsForSet();
|
||||
setOperations.remove(s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -3,12 +3,8 @@ package com.zhilian.online;
|
|||
import com.zhilian.common.security.annotation.EnableCustomConfig;
|
||||
import com.zhilian.common.security.annotation.EnableMyFeignClients;
|
||||
import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
|
||||
/**
|
||||
* @version:
|
||||
|
|
|
@ -14,8 +14,10 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -138,6 +140,32 @@ public class MqttxConfig {
|
|||
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||
log.info("消息到达,接受消息主题{},接受消息Qos{},接受消息内容{}", topic, mqttMessage.getQos(), new String(mqttMessage.getPayload()));
|
||||
|
||||
HashSet<String> strings = new HashSet<>();
|
||||
strings.add("malfunction");
|
||||
strings.add("event-storage");
|
||||
strings.add("geofence");
|
||||
|
||||
redisService.setCacheSet("vehicle-event:" + "VIN123456789DIJE4",strings);
|
||||
Set<Object> cacheSet = redisService.getCacheSet("vehicle-event:" + "VIN123456789DIJE4");
|
||||
|
||||
if (redisService.hasKey("vehicle-event:" + "VIN123456789DIJE4")){
|
||||
//有事件
|
||||
Set<Object> cacheSet1 = redisService.getCacheSet("vehicle-event:" + "VIN123456789DIJE4");
|
||||
Set<String> events = cacheSet1.stream().map(item -> {
|
||||
return String.valueOf(item);
|
||||
}).collect(Collectors.toSet());
|
||||
if (events.contains("geofence")){
|
||||
//包含围栏事件
|
||||
|
||||
}else {
|
||||
//不包含围栏事件
|
||||
redisService.setCacheSet("vehicle-event:" + "VIN123456789DIJE4","geofence");
|
||||
redisService.deleteCacheSet("vehicle-event:" + "VIN123456789DIJE4");
|
||||
events.add("geofence");
|
||||
redisService.setCacheSet("vehicle-event:" + "VIN123456789DIJE4",events);
|
||||
}
|
||||
}
|
||||
|
||||
//将接受到的车辆报文存储到kafka中
|
||||
executorService.execute(() -> {
|
||||
executorTask(mqttMessage);
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
package com.zhilian.online;
|
||||
|
||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-06 20:02
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class TestKafka {
|
||||
|
||||
@Autowired
|
||||
private KafkaTemplate<Object,Object> kafkaTemplate;
|
||||
|
||||
@Test
|
||||
public void testSend(){
|
||||
kafkaTemplate.send("topic1","hello world!");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package com.zhilian.resolver.service.impl.eventGeofence;
|
||||
|
||||
import com.zhilian.business.domain.Fence;
|
||||
import com.zhilian.business.domain.vo.FenceVo;
|
||||
import com.zhilian.common.business.domain.vo.FenceVo;
|
||||
import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||
import com.zhilian.resolver.service.ResolverEventService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
|
@ -19,11 +19,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.25.2:8848
|
||||
namespace: 9d9e22dc-ff70-42c5-adac-fa69e6d62dbe
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue