【问题标题】:Getting "dead letters encountered" using spray client使用喷雾客户端获取“遇到的死信”
【发布时间】:2016-02-17 13:45:56
【问题描述】:

我正在编写简单的喷雾客户端代码:

 // ActorSystem("main-actor-system") initialized earlier in code
implicit val system = actorSystem 
implicit val execctx: scala.concurrent.ExecutionContext = system.dispatcher
implicit val timeout = Timeout(10.seconds)

val pipeline: Future[pipelining.WithTransformerConcatenation[HttpRequest, Future[String]]] = 
for ( Http.HostConnectorInfo(connector, _) <-
     IO(Http) ? Http.HostConnectorSetup("myservicehost", port = 80)  
) yield sendReceive(connector) ~> unmarshal[String]

Await.ready(pipeline, 10 seconds)

// this is quite brute forse, what is better way?
val pl = pipeline.value.get.get

val response: Future[String] = pl { Get("/status")}
private val result: String = Await.result(response, 10 seconds)
response.foreach(r => println("result" + result))

每次我运行这段代码时,我都会得到

[INFO] [02/17/2016 15:31:15.596] [main-actor-system-akka.actor.default-dispatcher-3] [akka://main-actor-system/system/IO-TCP/selectors/$a/0] Message [akka.io.Tcp$Close$] from Actor[akka://main-actor-system/user/IO-HTTP/group-0/0#-1771046370] to Actor[akka://main-actor-system/system/IO-TCP/selectors/$a/0#1352725834] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

我应该怎么做才能解决这个问题?

【问题讨论】:

    标签: scala akka spray akka-http spray-client


    【解决方案1】:

    这不一定是个问题。这是来自documentation的sn-p。

    默认情况下,发送到死信的消息记录在信息级别。死信的存在并不一定表示有问题,但它可能是,因此默认情况下会记录它们。几条消息后,此日志记录被关闭,以避免日志泛滥。您可以完全禁用此日志记录或调整记录的死信数量。在系统关闭期间,您可能会看到死信,因为参与者邮箱中的待处理消息被发送到死信。您还可以在关机期间禁用死信记录。

    我在服务器启动时忽略它们。

    【讨论】:

    • 每次我向客户端发送请求时都会出现此日志。该系统容量很大,每个服务器请求最终都会调用 http 客户端(另一个微服务)。我可以在客户端配置/初始化中尽量使用它吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-11
    • 2012-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    相关资源
    最近更新 更多