是否可以暂停流,以便可以通过RPC调用恢复该流? [英] Is it possible to suspend a flow such that it can be resumed with an RPC-call?

查看:77
本文介绍了是否可以暂停流,以便可以通过RPC调用恢复该流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Corda中实现以下用例:
FlowA已通过 startFlowDynamic 在PartyA上调用。 FlowA创建一个部分签名的事务,并通过 sendAndReceive 在PartyB上调用FlowB。现在,人工用户应查看并手动批准此交易。理想情况下,FlowB应该在接收到事务后挂起。我希望能够通过RPC查询FlowB的暂停实例,并在我的UI中向用户展示这些实例(或其中的一些事务表示形式)。然后,在用户请求其批准后,我想通过RPC恢复FlowB,然后该RPC将签署该交易并将其返回给PartyA上的FlowA。

I am trying to implement the following use-case in Corda: FlowA has been invoked on PartyA via startFlowDynamic. FlowA creates a partially signed transaction and invokes FlowB on PartyB via sendAndReceive. A human user shall now review and manually approve this transaction. Ideally FlowB should suspend after receiving the transaction. I would like to be able to query for suspended instances of FlowB via RPC, and present those (or rather some representation of the transaction therein) to the user in my UI. Then, after the user actions his approval, I would like to resume FlowB via RPC, which would then sign the transaction and return it to FlowA on PartyA.

我注意到我可以通过CordaRPCOps.stateMachineAndUpdates在某种程度上检查挂起的流,并阅读了有关进度跟踪的教程,但是对于我的情况来说,这还不够。我还读到与人流互动被列为未来功能,我只是想知道是否还没有某种方法可以完成此任务?

I noticed that I can inspect suspended flows to some degree via CordaRPCOps.stateMachineAndUpdates and I read the tutorial on progress tracking, but it doesn't quite suffice for my case. I also read that interacting with people from flows is listed as a future feature, I just wondered if there isn't already some way to accomplish this ?

推荐答案

有关如何在实践中工作的示例,请参见协商Cordapp示例。此处

See the Negotiation Cordapp sample for an example of how this would work in practice here.

Corda当前不支持暂停用户交互流。

Corda doesn't currently support suspending a flow for user interaction.

但是,您可以支持此操作的工作流程如下。假设您正在编写用于贷款申请的CorDapp。您可能会有一个初始流程,该流程同意在两方之间创建 loanApplication 状态。从那里,批准者可以检查贷款申请,并启动批准流,该流创建交易以转换 loanApplication 进入 approvedLoan 状态,或者启动 reject 流以消耗 loanApplication 状态,而无需发出 approvedLoan 状态。

However, you can support this kind of workflow as follows. Suppose you're writing a CorDapp for loan applications. You could have an initial flow that agrees the creation of a loanApplicationstate between two parties. From there, the approver can inspect the loan application, and either kick off an approve flow that creates a transaction to transform the loanApplication into an approvedLoan state, or kick off a reject flow to consume the loanApplication state without issuing an approvedLoan state.

同样,您可以将状态字段添加到贷款状态,指定贷款是否得到批准。最初,贷款状态会将字段设置为未批准。然后,批准者可以启动两个流程之一来更新贷款状态,以使其具有批准的已拒绝状态。

Equally, you could add a status field to the loan state, specifying whether the loan is approved or not. Initially, the loan state would have the field set to unapproved. Then the approver could kick off one of two flows to update the loan state, to either have an approved or a rejected status.

这篇关于是否可以暂停流,以便可以通过RPC调用恢复该流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆