调用链码时,如何通知客户端应用程序? [英] How do I notify the client application when a chaincode is invoked?

查看:64
本文介绍了调用链码时,如何通知客户端应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用链码时,有一种方法可以调用REST API(外部),以便可以在新事务中通知客户端应用程序.

When a chaincode is invoked, is there a way to call a REST API (external) so that the client application can be notified on the new transaction.

除了REST之外,还有其他选择吗?

Apart from REST, is there any other option?

推荐答案

最好使用事件 https://github.com/hyperledger/fabric/blob/master/docs/protocol-spec.md#35-events

验证对等体和链码可以在网络上发出事件,应用程序可能会监听并采取措施.有一套预定义事件,并且链码可以生成自定义事件.大事记由1个或多个事件适配器消耗.适配器可能会进一步交付使用Web挂钩或Kafka等其他工具进行的事件.

Validating peers and chaincodes can emit events on the network that applications may listen for and take actions on. There is a set of pre-defined events, and chaincodes can generate custom events. Events are consumed by 1 or more event adapters. Adapters may further deliver events using other vehicles such as Web hooks or Kafka.

应用程序可以订阅来自Fabric的事件流,并侦听您的链码生成的消息.

Application can subscribe for events stream from Fabric and listen for messages generate by your chaincode.

可以在以下位置找到有关如何使用事件的示例: https://github.com/hyperledger/fabric/tree/master/examples/events/block-listener

An example for how to work with Events can be found here: https://github.com/hyperledger/fabric/tree/master/examples/events/block-listener

这篇关于调用链码时,如何通知客户端应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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