How to debug akka streams flows?

南楼画角 提交于 2019-12-13 19:28:10

问题


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)

回答1:


I have had similar issues with ScalaIDE.

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
}

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)

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



来源:https://stackoverflow.com/questions/33742233/how-to-debug-akka-streams-flows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!