From 0bab2292aa0094acf4d16c20de4aebef06b1d946 Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Fri, 14 Oct 2022 15:15:02 +0800 Subject: [PATCH] mark --- .../controller/InfluxDemoController.java | 23 ++++++++----------- .../com/qgs/dc/influx/param/InsertParam.java | 17 ++++++++++++++ .../com/qgs/dc/influx/template/Event.java | 1 + .../qgs/dc/mq/consumer/PID13SReceived.java | 1 - 4 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/qgs/dc/influx/param/InsertParam.java diff --git a/src/main/java/com/qgs/dc/influx/controller/InfluxDemoController.java b/src/main/java/com/qgs/dc/influx/controller/InfluxDemoController.java index 28547ad..63c0228 100644 --- a/src/main/java/com/qgs/dc/influx/controller/InfluxDemoController.java +++ b/src/main/java/com/qgs/dc/influx/controller/InfluxDemoController.java @@ -3,13 +3,17 @@ package com.qgs.dc.influx.controller; import com.influxdb.client.domain.WritePrecision; import com.influxdb.client.write.Point; import com.qgs.dc.influx.config.InfluxClient; +import com.qgs.dc.influx.param.InsertParam; import com.qgs.dc.influx.template.Event; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.time.Instant; +import java.util.ArrayList; +import java.util.List; @RestController @RequestMapping("/influx") @@ -36,19 +40,8 @@ public class InfluxDemoController { @PostMapping("/insertBatch") - public void insertBatch() throws InterruptedException { -// List list = new ArrayList<>(); -// -// for(int i=0;i<99;i++){ -// //Thread.sleep(1000); -// Event event = new Event(); -// event.time = Instant.now(); -// event.transationId = "asas"+i; -// event.argName = "arg5"; -// event.argValue = new Double(i); -// list.add(event); -// } -// influxService.batchInsert(list); + public void insertBatch(@RequestBody InsertParam insertParam) throws InterruptedException { + InfluxClient.Client.batchInsert(insertParam.getList(),insertParam.getMeasurement()); } @@ -73,4 +66,8 @@ public class InfluxDemoController { Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent"); InfluxClient.Client.insert(event,"ASProcessCompleteEvent"); } + + + + } diff --git a/src/main/java/com/qgs/dc/influx/param/InsertParam.java b/src/main/java/com/qgs/dc/influx/param/InsertParam.java new file mode 100644 index 0000000..58d462d --- /dev/null +++ b/src/main/java/com/qgs/dc/influx/param/InsertParam.java @@ -0,0 +1,17 @@ +package com.qgs.dc.influx.param; + +import com.qgs.dc.influx.template.Event; +import lombok.Data; + +import java.util.List; + +/** + * @Desc: "" + * @Author: caixiang + * @DATE: 2022/10/13 16:10 + */ +@Data +public class InsertParam { + List list; + String measurement; +} diff --git a/src/main/java/com/qgs/dc/influx/template/Event.java b/src/main/java/com/qgs/dc/influx/template/Event.java index f29fde2..822df54 100644 --- a/src/main/java/com/qgs/dc/influx/template/Event.java +++ b/src/main/java/com/qgs/dc/influx/template/Event.java @@ -13,6 +13,7 @@ import java.time.Instant; */ @Data public class Event { + private Instant time; private String transationId; diff --git a/src/main/java/com/qgs/dc/mq/consumer/PID13SReceived.java b/src/main/java/com/qgs/dc/mq/consumer/PID13SReceived.java index 86ddf02..8128897 100644 --- a/src/main/java/com/qgs/dc/mq/consumer/PID13SReceived.java +++ b/src/main/java/com/qgs/dc/mq/consumer/PID13SReceived.java @@ -71,7 +71,6 @@ public class PID13SReceived { } //2.模拟异常 ,然后 拒签消息 ,然后丢到死信队列 - //throw new Exception("11111"); }catch (Exception e){ // 第一个false 是 不批量签收;第二个false 是 不重回队列 logger.error(e.getMessage());