【问题标题】:Apache Camel: Preventing out of space while writing files [closed]Apache Camel:在写入文件时防止空间不足[关闭]
【发布时间】:2018-04-23 21:48:18
【问题描述】:

我正在使用 Apache Camel 在 tomcat 文件夹中创建一个文件队列,以将大量数据发布到休息服务。如果端点在几天内不可用并且由于它不断生成新文件而导致磁盘空间不足怎么办?如何防止这种情况发生?

【问题讨论】:

  • 您要问的内容太不清楚/太宽泛了。

标签: java apache apache-camel


【解决方案1】:

实现自定义Predicate以确保在写入文件之前有足够的可用空间。

类似这样的:

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();
}

【讨论】:

  • 不错的解决方案!有没有办法用 xml 创建这个谓词?
  • Nvm,我通过在 中使用 实现了它
猜你喜欢
  • 2020-05-26
  • 2013-06-26
  • 2013-10-05
  • 1970-01-01
  • 2014-05-04
  • 1970-01-01
  • 1970-01-01
  • 2016-04-04
  • 2019-11-13
相关资源
最近更新 更多