Reputation: 33
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)
}
}
}
something is wrong at sendAndReceive. Any kind of help is appreciated.
Upvotes: 0
Views: 105
Reputation: 36
Thanks for the code. It looks the the Acceptor
isn't sending a message back to the Initiator
?
Your Initiator
calls sendAndReceive<>
which means that it'll want to get something back from the Acceptor
. In this case the Acceptor
isn't sending the response back so we see the UnexpectedEndOfFLowException
(because the Initiator
expected something back but didn't get it).
I suspect you'd want to add a line in to send the NotificationModel
back:
@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 */)
}
}
See the following doc: https://docs.corda.net/api-flows.html#sendandreceive
Alternatively you could just call send
on the Initiator
if you don't expect a response back from the Acceptor
: https://docs.corda.net/api-flows.html#send
Upvotes: 2