parent
ae1a66ce02
commit
a37dd6cf56
|
@ -0,0 +1,15 @@
|
||||||
|
package com.mobai;
|
||||||
|
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.context.event.ContextClosedEvent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class MqttApplicationListener implements ApplicationListener<ContextClosedEvent> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(ContextClosedEvent event) {
|
||||||
|
|
||||||
|
System.out.println("下线前执行了");;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,10 +20,7 @@ import org.springframework.kafka.annotation.KafkaListener;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生产者/消费者
|
* 生产者/消费者
|
||||||
|
@ -71,7 +68,12 @@ public class KafkaPCUtils {
|
||||||
vin.getBytes(),
|
vin.getBytes(),
|
||||||
vehicleString,
|
vehicleString,
|
||||||
vehicleString.getBytes(),
|
vehicleString.getBytes(),
|
||||||
new Cluster("iYl5vA6ESGaoH5veXYGroQ", list, partitionInfos, null, null)
|
new Cluster(
|
||||||
|
"iYl5vA6ESGaoH5veXYGroQ",
|
||||||
|
list,
|
||||||
|
partitionInfos,
|
||||||
|
new HashSet<String>() {},
|
||||||
|
new HashSet<>())
|
||||||
);
|
);
|
||||||
log.info("当前获取分区:[{}]",partition);
|
log.info("当前获取分区:[{}]",partition);
|
||||||
// 创建消息 主题 key 分区 值
|
// 创建消息 主题 key 分区 值
|
||||||
|
|
Loading…
Reference in New Issue