This commit is contained in:
caixiang 2022-10-14 15:15:02 +08:00
parent 28591e74dc
commit 0bab2292aa
4 changed files with 28 additions and 14 deletions

View File

@ -3,13 +3,17 @@ package com.qgs.dc.influx.controller;
import com.influxdb.client.domain.WritePrecision; import com.influxdb.client.domain.WritePrecision;
import com.influxdb.client.write.Point; import com.influxdb.client.write.Point;
import com.qgs.dc.influx.config.InfluxClient; import com.qgs.dc.influx.config.InfluxClient;
import com.qgs.dc.influx.param.InsertParam;
import com.qgs.dc.influx.template.Event; import com.qgs.dc.influx.template.Event;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
@RestController @RestController
@RequestMapping("/influx") @RequestMapping("/influx")
@ -36,19 +40,8 @@ public class InfluxDemoController {
@PostMapping("/insertBatch") @PostMapping("/insertBatch")
public void insertBatch() throws InterruptedException { public void insertBatch(@RequestBody InsertParam insertParam) throws InterruptedException {
// List<Event> list = new ArrayList<>(); InfluxClient.Client.batchInsert(insertParam.getList(),insertParam.getMeasurement());
//
// 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);
} }
@ -73,4 +66,8 @@ public class InfluxDemoController {
Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent"); Point asProcessCompleteEvent = insert(event, "ASProcessCompleteEvent");
InfluxClient.Client.insert(event,"ASProcessCompleteEvent"); InfluxClient.Client.insert(event,"ASProcessCompleteEvent");
} }
} }

View File

@ -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<Event> list;
String measurement;
}

View File

@ -13,6 +13,7 @@ import java.time.Instant;
*/ */
@Data @Data
public class Event { public class Event {
private Instant time; private Instant time;
private String transationId; private String transationId;

View File

@ -71,7 +71,6 @@ public class PID13SReceived {
} }
//2.模拟异常 然后 拒签消息 然后丢到死信队列 //2.模拟异常 然后 拒签消息 然后丢到死信队列
//throw new Exception("11111");
}catch (Exception e){ }catch (Exception e){
// 第一个false 不批量签收第二个false 不重回队列 // 第一个false 不批量签收第二个false 不重回队列
logger.error(e.getMessage()); logger.error(e.getMessage());