|
|
@@ -1,9 +1,7 @@
|
|
|
package com.middle.platform.demo.controller;
|
|
|
|
|
|
-import com.middle.platform.demo.service.KafkaService;
|
|
|
-import jakarta.annotation.Resource;
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
@@ -15,53 +13,15 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RequestMapping("/kafka")
|
|
|
public class TestController {
|
|
|
|
|
|
- @Resource
|
|
|
- private KafkaService kafkaService;
|
|
|
-
|
|
|
/**
|
|
|
* 发送文本消息
|
|
|
*
|
|
|
- * @param msg
|
|
|
* @return
|
|
|
*/
|
|
|
- @GetMapping("/send/{msg}")
|
|
|
- public String send(@PathVariable String msg) {
|
|
|
- kafkaService.tet(msg);
|
|
|
- return "";
|
|
|
+ @GetMapping("/test")
|
|
|
+ public String send() {
|
|
|
+ return LocalDateTimeUtil.formatNormal(LocalDateTimeUtil.now());
|
|
|
}
|
|
|
|
|
|
-// /**
|
|
|
-// * 发送JSON数据
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// @GetMapping("/send2")
|
|
|
-// public String send2() {
|
|
|
-// Message message = new Message();
|
|
|
-// message.setId(System.currentTimeMillis());
|
|
|
-// message.setMsg("生产者发送消息到topic1: " + UUID.getUUID32());
|
|
|
-// message.setSendTime(new Date());
|
|
|
-//
|
|
|
-// String value = JSON.toJSONString(message);
|
|
|
-// log.info("生产者发送消息到topic1 message = {}", value);
|
|
|
-//
|
|
|
-// kafkaService.send(kafkaConfiguration.getMyTopic1(),value);
|
|
|
-// return value;
|
|
|
-// }
|
|
|
-// /**
|
|
|
-// * 发送JSON数据
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// @GetMapping("/send3")
|
|
|
-// public String send3() {
|
|
|
-// Message message = new Message();
|
|
|
-// message.setId(System.currentTimeMillis());
|
|
|
-// message.setMsg("生产者发送消息到topic2: " + UUID.getUUID32());
|
|
|
-// message.setSendTime(new Date());
|
|
|
-//
|
|
|
-// String value = JSON.toJSONString(message);
|
|
|
-// log.info("生产者发送消息到topic2 message = {}", value);
|
|
|
-//
|
|
|
-// kafkaService.send(kafkaConfiguration.getMyTopic2(),value);
|
|
|
-// return value;
|
|
|
-// }
|
|
|
+
|
|
|
}
|