【问题标题】:camel - how to receive metrics data for counter骆驼 - 如何接收计数器的指标数据
【发布时间】:2014-09-29 10:53:02
【问题描述】:

我想要一个检查计数器是否达到特定值的谓词。是否可以从指标计数器中获取值?

from("file:/some/file/to/check.txt").id("read-file")
    .split()
    .tokenize("\n")
    .streaming()
    .parallelProcessing()
    .to("metrics:counter:simple.counter")
    .to("direct:test");

from("direct:test").id("do-something")
    . // do something
    .aggregate(constant(true), aggregationStrategy)
    .completionPredicate(counterPredicate)
    . // do something after finished all lines
    .to("direct:end");

我需要一些关于 counterPredicate 的帮助。

【问题讨论】:

    标签: spring apache-camel counter metrics


    【解决方案1】:

    我宁愿使用 AtomicInteger,把它放在骆驼上下文中来访问和增加它。使用 MVEL 构成完成谓词。

    谓词应类似于:

    mvel("this.context.property.counter == this.context.property.DESIRED_VALUE")
    

    【讨论】:

      【解决方案2】:

      camel-metrics 端点不支持创建消费者,恐怕您需要在 counterPredicate 中自己访问 MetricsRegistry。

      MetricRegistryService registryService = camelContext.hasService(MetricsRegistryService.class);
      if (registryService != null) {
          MetricsRegistry registry = registryService.getMetricsRegistry();
          ...
       }
      

      【讨论】:

        猜你喜欢
        • 2017-02-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-04-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多