我正在使用akka streams graphDSL来创建一个可运行的图形。流组件的入口/出口没有编译时错误。运行时抛出以下错误:
任何想法我应该验证什么才能让它运行?
requirement failed: The inlets [] and outlets [] must correspond to the inlets [in] and outlets [out]
at scala.Predef$.require(Predef.scala:219)
at akka.stream.Shape.requireSamePortsAs(Shape.scala:168)
at akka.stream.impl.StreamLayout$CompositeModule.replaceShape(StreamLayout.scala:390)
at akka.stream.scaladsl.GraphApply$class.create(GraphApply.scala:18)
at akka.stream.scaladsl.GraphDSL$.create(Graph.scala:813)
at com.flipkart.connekt.busybees.streams.Topology$.bootstrap(Topology.scala:109)
at com.flipkart.connekt.busybees.BusyBeesBoot$.start(BusyBeesBoot.scala:65)
at com.flipkart.connekt.boot.Boot$.delayedEndpoint$com$flipkart$connekt$boot$Boot$1(Boot.scala:39)
at com.flipkart.connekt.boot.Boot$delayedInit$body.apply(Boot.scala:13)
图结构:
source ~> flowRate ~> render ~> platformPartition.in
platformPartition.out(0) ~> formatIOS ~> apnsDispatcher ~> apnsEventCreator ~> merger.in(0)
platformPartition.out(1) ~> formatAndroid ~> httpDispatcher ~> gcmPoolFlow ~> rHandlerGCM ~> merger.in(1)
merger.out ~> evtCreator ~> Sink.ignore
答案 0 :(得分:16)
您有一个未使用的入口或出口(您的一个流量或所有侧面没有连接的东西)。以下是一些例子:
这有效:
val workingFlow =
Flow.fromGraph(GraphDSL.create() { implicit b =>
import GraphDSL.Implicits._
val intFlow = b.add(Flow[Int])
FlowShape(intFlow.in, intFlow.out)
})
以下代码会产生与您类似的错误,因为它有一个完整的未使用的流程:
val buggyFlow =
Flow.fromGraph(GraphDSL.create() { implicit b =>
import GraphDSL.Implicits._
val intFlow = b.add(Flow[Int])
val unusedFlow = b.add(Flow[Int]) // ERROR: This flow is unused
FlowShape(intFlow.in, intFlow.out)
})
一个稍微复杂的例子:这里没有一个完整的未使用流量,只有一个未使用的插座。它产生相同的错误:
val buggyFlow =
Flow.fromGraph(GraphDSL.create() { implicit b =>
import GraphDSL.Implicits._
val broadcast = b.add(Broadcast[Int](2))
val intFlow = b.add(Flow[Int])
val unusedFlow = b.add(Flow[Int]) // ERROR: This flow's outlet isn't used
broadcast ~> intFlow
broadcast ~> unusedFlow
FlowShape(broadcast.in, intFlow.out)
})