问题
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