我的问题是,当我创建第二种状态时,Corda会引发异常。这里是例外:“ message”:“ net.corda.core.flows.UnexpectedFlowEndException:对方在意外的时间发送了会话拒绝消息,并显示消息无法建立会话。但是第一状态可以存储在Corda的默认数据库中。
这很奇怪。
first state:[
{
"foud_name": "23",
"financing_name":"23",
"financing_project":"23",
"company_name":"23",
"data_producer":"23",
"attachment_name":"23",
"attachment_type":"23",
"attachment_id":"23"
}
]
当我存储第二个时,它会引发异常:
{
"timestamp": "2018-08-24T09:47:02.654+0000",
"status": 500,
"error": "Internal Server Error",
"message": "net.corda.core.flows.UnexpectedFlowEndException: Counterparty sent session rejection message at unexpected time with message Unable to establish session",
"path": "/api/v1/resarch-attachment"
}
答案 0 :(得分:0)
此错误消息表明:
有几种可能的原因。响应流可能已经结束,或者此时可能不希望收到消息。
您说错误消息仅第二次发生。有了我的详细信息,我假设您的启动流程正在尝试使交易对手多次调用响应流程。像这样:
@InitiatingFlow
@StartableByRPC
class InitiatorFlow(val counterparty: Party) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
val counterpartySession = initiateFlow(counterparty)
(0..99).forEach {
counterpartySession.send("My payload.")
}
}
}
@InitiatedBy(InitiatorFlow::class)
class ResponderFlow(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
counterpartySession.receive<String>()
}
}
这将不起作用。启动启动流时,将为其指定流ID。与交易对手通信时使用此ID来告诉他们使用哪个响应流:
相反,您需要使用子流为与交易对手的每次通信创建一个新的流ID。像这样:
@InitiatingFlow
@StartableByRPC
class InitiatorFlow(val counterparty: Party) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
(0..99).forEach {
subFlow(SendMessageFlow(counterparty))
}
}
}
@InitiatingFlow
class SendMessageFlow(val counterparty: Party) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
val counterpartySession = initiateFlow(counterparty)
counterpartySession.send("My payload.")
}
}
@InitiatedBy(SendMessageFlow::class)
class ResponderFlow(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
counterpartySession.receive<String>()
}
}