Scala Akka图形流无法生成输出
我只是在玩akka流文档页面上给出的示例: 下面的例子取自那个里并没有产生输出。有人能指出这里出了什么问题吗 更新:从终端开始工作。但是Intellij失败了 我的SBT依赖项是:Scala Akka图形流无法生成输出,scala,akka,akka-stream,Scala,Akka,Akka Stream,我只是在玩akka流文档页面上给出的示例: 下面的例子取自那个里并没有产生输出。有人能指出这里出了什么问题吗 更新:从终端开始工作。但是Intellij失败了 我的SBT依赖项是: val akkaVersion = "2.3.7" val httpVersion = "2.0.4" libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % "2.3.11", "com.typesafe.akka" %% "ak
val akkaVersion = "2.3.7"
val httpVersion = "2.0.4"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.3.11",
"com.typesafe.akka" %% "akka-stream-experimental" % httpVersion,
"com.typesafe.akka" %% "akka-http-core-experimental" % httpVersion,
"com.typesafe.akka" %% "akka-http-experimental" % httpVersion,
"com.typesafe.akka" %% "akka-http-spray-json-experimental" % httpVersion
)
节目:
import akka.stream.ClosedShape
object Test extends App {
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.scaladsl._
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
implicit val ec = system.dispatcher
val source = Source(Stream.from(1))
val graph = RunnableGraph.fromGraph(GraphDSL.create() { implicit b =>
import GraphDSL.Implicits._
val zip = b.add(ZipWith((left: Int, right: Int) => left))
val bcast = b.add(Broadcast[Int](2))
val concat = b.add(Concat[Int]())
val start = Source.single(0)
source ~> zip.in0
zip.out.map { s => println(s); s } ~> bcast ~> Sink.ignore
zip.in1 <~ concat <~ start
concat <~ bcast
ClosedShape
})
graph.run()
Thread.sleep(1000000)
}
导入akka.stream.ClosedShape
对象测试扩展应用程序{
导入akka.actor.ActorSystem
导入akka.stream.Actormatarializer
导入akka.stream.scaladsl_
隐式val system=ActorSystem()
隐式val-materializer=actormatarializer()
隐式val ec=system.dispatcher
val source=源(来自(1)的流)
val graph=RunnableGraph.fromGraph(GraphDSL.create(){implicit b=>
导入GraphDSL.Implicits_
val zip=b.add(ZipWith((左:Int,右:Int)=>左))
val bcast=b.add(广播[Int](2))
val concat=b.add(concat[Int]())
val start=Source.single(0)
source~>zip.in0
zip.out.map{s=>println(s);s}~>bcast~>Sink.ignore
zip.in1您使用什么来运行此应用程序?使用SBT对我很好。您可以尝试使用(例如,val Source=Source(Stream.from(1))。延迟(50毫秒,溢出策略。背压)来降低源吞吐量
它正在从终端运行,但intellij运行失败。正如您所说,代码没有问题。它运行时没有引发任何错误。可能是intellij环境中的某些配置错误。如果您提供详细信息(异常、错误消息等),我们可以提供更好的帮助。