Re: Fabric Java SDK for using Channel-based event hub service #fabric-sdk-java #fabric-sdk-node #hyperledger-fabric


Mark Lewis
 

You are correct that EventHub is the wrong thing to be using, and this is removed in the v2.x SDK. If possible, I would strongly recommend using fabric-gateway-java rather than fabric-sdk-java. It layers on top of fabric-sdk-java and provides a much more friendly API, saving you worrying about the implementation details of what event service you are using. Documentation can be found at:

You can receive block events by simply adding your block listener to a Network object (which corresponds to a Channel):

Using this API you get fault tolerance, block ordering and deduplication for free. From a block event you can iterate over the transaction events contained within that block.

The fabric-gateway-java API already deals with monitoring transaction commit events after submitting a transaction for you, but if you really need to observe when transactions get committed on each of a set of peers, you can do that by adding a commit listener to a Network object.

If you want to do work in response to chaincode events emitted by committed transactions, you can do this by adding a contract listener to a Contract object (which corresponds to a smart contract / chaincode):

Join fabric@lists.hyperledger.org to automatically receive all group messages.