我收到以下错误:
java.lang.IllegalArgumentException: requirement failed: The inlets [] and outlets [BlockOut.out] must correspond to the inlets [] and outlets [BlockOut.out]
我有一个非常简单的图表:
val g1 = GraphDSL.create() { implicit builder =>
import GraphDSL.Implicits._
val in: Source[ByteString, Any] = Source.single(ByteString(digest))
val flow: GraphStage[FlowShape[ByteString, ByteString]] = new ReadBlockStage(dataStore, blockingExecutionContext)
in ~> flow
SourceShape(flow.shape.out)
}
val sourceGraph: Source[ByteString, NotUsed] = Source.fromGraph(g1)
我的流程定义如下:
class ReadBlockStage(dataStore: DataStore, implicit val exceutionContext: ExecutionContext) extends GraphStage[FlowShape[ByteString, ByteString]] with DefaultJsonProtocol {
val in = Inlet[ByteString]("DigestSpec.in")
val out = Outlet[ByteString]("BlockOut.out")
override val shape = FlowShape.of(in, out)
...
}
为什么我收到此错误?流程" out"端口的类型为Outlet[ByteString]
,我的Source
为Source[ByteString, NotUsed]
。错误消息非常混乱,因为它看起来像形状和预期的形状是相同的。
答案 0 :(得分:2)
我想出了这个问题。我忘了为每个图元素执行builder.add()。