0

Am trying to upgrade my fabric sdk java from 1.4 to 2.2 version Is see eventhub being removed from 2.x version Now how should I register my events and how should I wait for chain code events in 2.2 version Am new to hyperledger, can someone help me on this please.Is there any samples for this

Anu
  • 1
  • 4

1 Answers1

0

Just by way of background, the event hub service was superseded by the peer channel-based event service in Fabric v1.1. If you're set on using the fabric-sdk-java API then you have registerChaincodeEventListener() on the Channel object. Be aware that you might receive duplicate or out-of-order events.

I would strongly recommend that you use the fabric-gateway-java API, which allows you to listen to chaincode events using addContractListener() on the Contract object:

https://hyperledger.github.io/fabric-gateway-java/release-2.2/org/hyperledger/fabric/gateway/Contract.html

This will give you events in order and without duplication, replay of events, and checkpointing to allow you to resume listening from your last received event after a client application restart. As well as a generally much more friendly API to work with.

bestbeforetoday
  • 1,302
  • 1
  • 8
  • 12