如何调试Akka流? [英] How to debug akka streams flows?

查看:126
本文介绍了如何调试Akka流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在processLine方法中的某个位置放置断点时,调试器不会在该行处停止.它执行起来好像没有任何断点.调试akka流是否有些不同,我该如何解决这个问题?

When I drop a breakpoint somewhere in method processLine, debugger does not stop at the line. It executes as if there is not any breakpoint .Is debugging akka streams flows somewhat different, how can i solve this issue?

val stream = source.
                 map( csvLine => A.processLine(csvLine)).
                 runWith(Sink)

推荐答案

我在 ScalaIDE 中遇到了类似的问题.

I have had similar issues with ScalaIDE.

我的解决方案通常是将我的业务逻辑"与任何akka依赖项隔离:

My solution has generally been to isolate my "business logic" from any akka dependencies:

//no akka imports required

case class Tweet(val author : String, val body : String)

def validAuthor(author : String) : Boolean = {
  author.trim().size > 0 && !author.equalsIgnoreCase("jk_rowling") //breakpoint works here
}

然后我的异步代码变成对buz逻辑的简单调用:

Then my asynchronous code becomes simple calls to the buz logic:

import akka.stream.scaladsl.{Source, Sink}

val source : Source[Tweet,_] = ???

val flow = source.filter(validAuthor)
                 .runWith(Sink foreach println)

然后,IDE遵循buz逻辑中的断点,例如在validAuthor之内.

The IDE then obeys breakpoints in the buz logic, e.g. within validAuthor.

这篇关于如何调试Akka流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆