net.corda.core.flows.UnexpectedFlowEndException: пытался получить доступ к завершенному сеансу SessionId (toLong = 8223329095323268490) с пустым буфером - PullRequest
0 голосов
/ 31 октября 2019
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. Любая помощь приветствуется.

1 Ответ

4 голосов
/ 31 октября 2019

Спасибо за код. Похоже, Acceptor не отправляет сообщение обратно на Initiator?

Ваши Initiator звонки sendAndReceive<>, что означает, что он захочет получить что-то обратно от Acceptor,В этом случае Acceptor не отправляет ответ обратно, поэтому мы видим UnexpectedEndOfFLowException (потому что Initiator ожидал что-то назад, но не получил его).

Я подозреваю, что вы захотитечтобы добавить строку для отправки NotificationModel назад:

@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

В качестве альтернативы вы можете просто позвонить send на Initiator, есливы не ожидаете ответа от Acceptor: https://docs.corda.net/api-flows.html#send

...