是否可以在Corda中创建响应者流链?例如。 FlowA-(启动)-> FlowB-(启动)-> FlowC

时间:2019-02-07 04:41:07

标签: corda

我创建了3个流FlowA,FlowB和FlowC。 FlowA启动FlowB,而FlowB启动FlowC。以下是我的代码的外观:

@StartableByRPC
@InitiatingFlow
class FlowA(val message: String) : FlowLogic<Unit>() {

    override val progressTracker = ProgressTracker()

    @Suspendable
    override fun call() {
        println("FlowA")
        initiateFlow(ourIdentity).send(message)
        println("FlowA End")
    }
}

@InitiatedBy(FlowA::class)
@InitiatingFlow
class FlowB(val flowASession: FlowSession) : FlowLogic<Unit>() {

    override val progressTracker = ProgressTracker()

    @Suspendable
    override fun call() {

        val message: String = flowASession.receive(String::class.java).unwrap {
            it
        }

        println("FlowB " + message)

        initiateFlow(ourIdentity).send(message)

        println("FlowB End")
    }
}

@InitiatedBy(FlowB::class)
class FlowC(val flowBSession: FlowSession) : FlowLogic<Unit>() {

    override val progressTracker = ProgressTracker()

    @Suspendable
    override fun call() {

        val message: String = flowBSession.receive(String::class.java).unwrap {
            it
        }

        println("FlowC " + message)
    }
}

当我通过在外壳中传递消息“ Hi”触发FlowA时,得到以下输出:

FlowA
FlowA End
FlowB Hi
Done
Flow completed with result: kotlin.Unit 

为什么FlowC不被触发而FlowB被卡住?我如何才能使其正常工作?

0 个答案:

没有答案