下面我试图使用批次wirte
private void save() {
Pong pong = conn.ping();
if (pong != null && pong.isGood()) {
LogUtil.info("InfluxDBStreamOutputStep",
String.format("prepare to write %d line datas", batchPoints.getPoints().size()));
conn.batchInsert(batchPoints);
}
}
这个bolck设置了连接,我写了一个try catch,用于在中断或发生任何错误时重建新连接
@Override
protected void processClose(){
try {
if (batchPoints != null && batchPoints.getPoints() != null
&& !batchPoints.getPoints().isEmpty()) {
long start = System.currentTimeMillis();
try {
save();
}
catch(InfluxDBException e) {
if (conn != null) {
conn.close();
}
setupConnection();
save();
}
}
}
}
在我添加了重建代码blokc后,它可以继续运行超过五天,但异常发生在今天,它与“borken管道”之前的日子相同 . 我搜索了管道损坏的原因,并且某人博客的答案说破管发生了当客户在写入数据期间重新获得第一个包时 . 总之,有人知道解决方案还是之前遇到过这个问题?