Akka - 如何查看邮件在收件箱中的时长?

时间:2015-04-22 14:17:20

标签: scala akka

如何检查akka收件箱中邮件的时长?如果邮件在收件箱中的时间太长,我想发一条日志消息。类似的东西:

override def receive: Receive = {
   case Message =>
      val timeInInbox = ...
      if (timeInInbox > treshold) log.warn("bla bla bla the doom is coming")

2 个答案:

答案 0 :(得分:3)

有可用于提供此信息的指标/遥测库。 一个是kamon.io(开源),它为您提供了“邮箱时间”指标,请参阅http://kamon.io/documentation/kamon-akka/0.6.6/actor-router-and-dispatcher-metrics/

另一个(非免费的,封闭的来源)是“Lightbend Telemetry”,称之为“邮箱时间”,请参阅http://developer.lightbend.com/docs/monitoring/latest/instrumentations/akka/akka.html#actor-metrics

答案 1 :(得分:0)

Akka目前没有内置任何功能。

您可以创建一个自定义邮箱实现,记录每个邮件的到达时间dequeue,并将队列持续时间记录在getCurrentTimeMillis上。见" Creating your own Mailbox type"在Akka文档中。

请注意,调用<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text="Page 1" android:id="@+id/textViewHeader" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:padding="10dip" android:textStyle="bold"></TextView> <android.support.v4.view.ViewPager android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/viewPager" /> </LinearLayout> 或类似邮件并不便宜,因此您可能会发现此类邮箱的性能成本很高。我希望这就是为什么Akka没有开箱即用的原因。

相关问题