package com.xiaopeng.automaticPilot.controller;
|
|
import com.alibaba.fastjson2.JSON;
|
import com.xiaopeng.api.vo.automaticPilot.proto.up.MsgContent;
|
import com.xiaopeng.automaticPilot.service.KafkaConsumerService;
|
import io.swagger.annotations.Api;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.kafka.annotation.KafkaListener;
|
import org.springframework.web.bind.annotation.*;
|
|
/**
|
* Kafka 测试控制器
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/kafka")
|
@Api(tags = "Kafka 测试接口")
|
public class KafkaTestController {
|
|
@Autowired
|
private KafkaConsumerService kafkaConsumerService;
|
|
|
|
|
/**
|
* 消费消息 - XPU上报Robotaxi云端的消息topic(高优先级)
|
*
|
* @param message 消息内容
|
*/
|
@KafkaListener(topics = "topic-prod-robotaxi-xpu-high", groupId = "group-robotaxi-xpu")
|
public void topicProdRobotaxiXpuHigh(String message) {
|
try {
|
log.info("收到XPU上报高优先级主题消息: {}", message);
|
kafkaConsumerService.topicProdRobotaxiXpuHigh(message);
|
} catch (Exception e) {
|
log.error("处理XPU上报高优先级主题消息失败: {}", message, e);
|
throw e;
|
}
|
}
|
|
/**
|
* 消费消息 - XPU上报Robotaxi云端的消息topic(低优先级)
|
*
|
* @param message 消息内容
|
*/
|
@KafkaListener(topics = "topic-prod-robotaxi-xpu-normal", groupId = "group-robotaxi-xpu")
|
public void topicProdRobotaxiXpuNormal(String message) {
|
try {
|
log.info("收到XPU上报低优先级主题消息: {}", message);
|
kafkaConsumerService.topicProdRobotaxiXpuNormal(message);
|
} catch (Exception e) {
|
log.error("处理XPU上报低优先级主题消息失败: {}", message, e);
|
throw e;
|
}
|
}
|
}
|