作者:呢嘚吖頭ing_311 | 来源:互联网 | 2023-01-09 13:39
我正在使用Apache Camel在tomcat文件夹中创建一个文件队列,以便将大量数据发送到休息服务.如果端点在几天内不可用并且磁盘空间不足,因为它不断创建新文件会怎么样?如何防止这种情况发生?
1> Bedla..:
实现自定义谓词以确保在写入文件之前有足够的可用空间.
像这样的东西:
private static final Predicate IS_ENOUGH_SPACE = exchange -> {
return new File(Paths.get("").toUri()).getUsableSpace() > 100*1024*1024; // 100MB
};
public void configure() {
from("timer:simple?period=1000")
.choice().when(IS_ENOUGH_SPACE)
.to("file://myStuff")
.to("log:done")
.otherwise()
.to("log:supressed") // do some handling here, maybe pause route for while
.end();
}