首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >net.corda.core.flows.UnexpectedFlowEndException:尝试访问结束的会话SessionId(toLong=8223329095323268490),缓冲区为空

net.corda.core.flows.UnexpectedFlowEndException:尝试访问结束的会话SessionId(toLong=8223329095323268490),缓冲区为空
EN

Stack Overflow用户
提问于 2019-10-31 16:22:55
回答 1查看 78关注 0票数 0
代码语言:javascript
运行
复制
class Initiator(private val notificationObject: NotificationModel, private val counterParty: Party) : FlowLogic<Unit>() {

        @Suspendable
        override fun call() {

            val counterPartySession = initiateFlow(counterParty)
            val counterPartyData = counterPartySession.sendAndReceive<NotificationModel>(notificationObject)
            counterPartyData.unwrap { msg ->
                assert(msg.notification_data == notificationObject.notification_data)
            }
        }
    }

sendAndReceive出了点问题。任何形式的帮助都是值得感谢的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-31 18:32:37

谢谢你的代码。看起来Acceptor没有向Initiator发回消息

您的Initiator调用sendAndReceive<>,这意味着它想要从Acceptor获取一些东西。在本例中,Acceptor没有发回响应,所以我们看到了UnexpectedEndOfFLowException (因为Initiator期望得到一些东西,但是没有得到)。

我怀疑您可能想要添加一行代码来将NotificationModel发回:

代码语言:javascript
运行
复制
@InitiatedBy(Initiator::class)
class Acceptor(private val counterpartySession: FlowSession) : FlowLogic<Unit>() { 

    @Suspendable override fun call() { 
        val counterPartyData = counterpartySession.receive<NotificationModel>() 
        counterPartyData.unwrap { msg -> //code goes here } 
        counterPartySession.send(/* some payload of type NotificationModel here */)
    } 
}

请参阅以下文档:https://docs.corda.net/api-flows.html#sendandreceive

或者,如果您不期望从Acceptorhttps://docs.corda.net/api-flows.html#send返回响应,可以只在Initiator上调用Acceptor

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58639296

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档