{"id":13625152,"url":"https://github.com/IBM/Leveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork","last_synced_at":"2025-04-16T06:32:03.584Z","repository":{"id":56638844,"uuid":"126889825","full_name":"IBM/Leveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork","owner":"IBM","description":"WARNING: This repository is no longer maintained :warning: This repository will not be updated. The repository will be kept available in read-only mode.","archived":true,"fork":false,"pushed_at":"2020-10-27T17:35:56.000Z","size":13574,"stargazers_count":29,"open_issues_count":2,"forks_count":19,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-08-01T22:04:14.057Z","etag":null,"topics":["blockchain-network","hyperledger-fabric","ibmcode","rabbitmq-cluster"],"latest_commit_sha":null,"homepage":"https://developer.ibm.com/code/patterns/integrate-rabbitmq-and-redis-cluster-with-a-blockchain-network/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IBM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-26T21:04:52.000Z","updated_at":"2023-07-02T07:17:10.000Z","dependencies_parsed_at":"2022-08-15T22:20:54.122Z","dependency_job_id":null,"html_url":"https://github.com/IBM/Leveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2FLeveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2FLeveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2FLeveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2FLeveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IBM","download_url":"https://codeload.github.com/IBM/Leveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223700263,"owners_count":17188287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain-network","hyperledger-fabric","ibmcode","rabbitmq-cluster"],"created_at":"2024-08-01T21:01:51.415Z","updated_at":"2025-04-16T06:32:03.577Z","avatar_url":"https://github.com/IBM.png","language":"JavaScript","readme":"# WARNING: This repository is no longer maintained :warning: \nThis repository will not be updated. The repository will be kept available in read-only mode.\n\n# Leveraging the Cache and Messaging Queue to Scale a Blockchain Network\n\n*Read this in other languages: [한국어](README-ko.md).*\n\nIn this step, we will configure Redis and RabbitMQ cluster in our architecture to control the flow of incoming request to blockchain network. With the direct use of REST API calls, it is not possible to control the number of requests sent to blockchain network, this might cause errors such as read/write conflicts etc. In order to control the flow of request sent to blockchain network and scale our application, we will use RabbitMQ cluster with 3 nodes consisting of mirrored queues to queue the user requests and Redis cluster with 6 nodes (3 leaders and 3 followers) where results of execution are store for a short duration. In architecture diagram, we have RabbitMQ producer present in API containers that queue the requests to RabbitMQ cluster and RabbitMQ consumers configured with an instance of Fabric-Node-SDK in Task execution containers to consume the requests from users and send it blockchain network for execution.\n\nYou will find the configuration code for Redis in `./backend/utils/util.js`.\n\nYou will find the configuration code for RabbitMQ in `./rabbitClient/utils/util.js`\n\n## Included Components\n* Hyperledger Fabric\n* Docker\n* Hyperledger Fabric SDK for node.js\n\n\n## Application Workflow Diagram\n![Application Workflow](images/arch.png)\n\n1. Issue a `git clone https://github.com/IBM/Leveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork`.\n2. Issue the command `build.sh` to setup the network.\n\n## Prerequisites\n* [Docker](https://www.docker.com/products) - v1.13 or higher\n* [Docker Compose](https://docs.docker.com/compose/overview/) - v1.8 or higher\n\n## Steps\n1. [Run Build.sh Script to build  and start the network](#1-run-the-build.sh-script)\n2. [Check the logs to see the results](#2-check-the-logs)\n3. [Test the Blockchain Network](#3-test-the-blockchainnetwork)\n\n## 1. Run the Build.sh Script\nThis accomplishes the following:\n\na. Clean up system by removing any existing blockchain docker images\n\nb. Generate certificates\n\n\n  * The `crypto-config.yaml` (Crypto configuration file) defines the identity of \"who is who\". It tells peers and orderers what organization they belown to and what domain they belong to.\n\n\nc.  Create Peers, Orderers and Channel\n\n  * The `configtx.yaml` file initializes a blockchain network or channel and services with an Orderer Genesis Block which serves as the first block on a chain. Additionally, membership services are installed on each channel peer (in this case, the Shop and Fitcoin Peers).\n\nd. Build docker images of the orderer, peers, channel, network\n\n### Open a new terminal and run the following command:\n```bash\nexport FABRIC_CFG_PATH=$(pwd)\nchmod +x cryptogen\nchmod +x configtxgen\nchmod +x generate-certs.sh\nchmod +x generate-cfgtx.sh\nchmod +x docker-images.sh\nchmod +x build.sh\nchmod +x clean.sh\n./build.sh\n```\n\n## 2. Check the logs\n\n**Command**\n```bash\ndocker logs blockchain-setup\n```\n**Output:**\n```bash\nCA registration complete\nCA registration complete\nDefault channel not found, attempting creation...\nSuccessfully created a new default channel.\nJoining peers to the default channel.\nChaincode is not installed, attempting installation...\nBase container image present.\ninfo: [packager/Golang.js]: packaging GOLANG from bcfit\ninfo: [packager/Golang.js]: packaging GOLANG from bcfit\nSuccessfully installed chaincode on the default channel.\nSuccessfully instantiated chaincode on all peers.\nBlockchain network setup complete.\n```\n\n**Command**\n```bash\ndocker ps\n```\n**Output:**\n```bash\nf4ddfcb1e4d8        haproxy:1.7                                                                              \"/docker-entrypoint.…\"   5 minutes ago       Up 5 minutes        0.0.0.0:3000-\u003e3000/tcp                                rabbitclient\n5f40495511f1        backend                                                                                  \"node index.js\"          5 minutes ago       Up 5 minutes                                                              fitcoin_fitcoin-backend_1\n6ea304c78c40        backend                                                                                  \"node index.js\"          5 minutes ago       Up 5 minutes        0.0.0.0:3030-\u003e3030/tcp                                fitcoin_shop-backend_1\nef481c334532        rabbit-client                                                                            \"node index.js\"          5 minutes ago       Up 5 minutes        0.0.0.0:3003-\u003e3000/tcp                                rabbitclient3\n51b7c6cee311        rabbit-client                                                                            \"node index.js\"          5 minutes ago       Up 5 minutes        0.0.0.0:3002-\u003e3000/tcp                                rabbitclient2\n1195c7cb43ca        rabbit-client                                                                            \"node index.js\"          5 minutes ago       Up 5 minutes        0.0.0.0:3001-\u003e3000/tcp                                rabbitclient1\n15533fe3a151        redis-server                                                                             \"/docker-entrypoint.…\"   5 minutes ago       Up 5 minutes        6379/tcp, 0.0.0.0:7000-7005-\u003e7000-7005/tcp            fitcoin_redis-server_1\n556840abfc4d        dev-shop-peer-bcfit-1-0e0d4e71de9ac7df4d0d20dfcf583e3e63227edda600fe338485053387e09c50   \"chaincode -peer.add…\"   6 minutes ago       Up 6 minutes                                                              dev-shop-peer-bcfit-1\n8c594ddc16f4        haproxy:1.7                                                                              \"/docker-entrypoint.…\"   6 minutes ago       Up 6 minutes        0.0.0.0:5672-\u003e5672/tcp, 0.0.0.0:15672-\u003e15672/tcp      rabbitmq\nc59da84a4e7c        rabbitmq:3-management                                                                    \"/usr/local/bin/clus…\"   6 minutes ago       Up 6 minutes        4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   rabbitmq2\nf07024afd0f1        rabbitmq:3-management                                                                    \"/usr/local/bin/clus…\"   6 minutes ago       Up 6 minutes        4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   rabbitmq3\n7ef2085afd54        rabbitmq:3-management                                                                    \"docker-entrypoint.s…\"   6 minutes ago       Up 6 minutes        4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   rabbitmq1\n2a775a81c967        blockchain-setup                                                                         \"node index.js\"          7 minutes ago       Up 7 minutes        3000/tcp                                              blockchain-setup\n90136f4c90fe        fitcoin-peer                                                                             \"peer node start\"        7 minutes ago       Up 7 minutes        0.0.0.0:8051-\u003e7051/tcp, 0.0.0.0:8053-\u003e7053/tcp        fitcoin-peer\n19e4890f71e3        shop-peer                                                                                \"peer node start\"        7 minutes ago       Up 7 minutes        0.0.0.0:7051-\u003e7051/tcp, 0.0.0.0:7053-\u003e7053/tcp        shop-peer\n654ada9fbbf6        ishangulhane/fabric-couchdb                                                              \"tini -- /docker-ent…\"   7 minutes ago       Up 7 minutes        4369/tcp, 9100/tcp, 0.0.0.0:9984-\u003e5984/tcp            shop-statedb\nb19022ef3b2a        ishangulhane/fabric-couchdb                                                              \"tini -- /docker-ent…\"   7 minutes ago       Up 7 minutes        4369/tcp, 9100/tcp, 0.0.0.0:5984-\u003e5984/tcp            ca-datastore\n6360ff012bbd        fitcoin-ca                                                                               \"fabric-ca-server st…\"   7 minutes ago       Up 7 minutes        0.0.0.0:8054-\u003e7054/tcp                                fitcoin-ca\n9d06dd0a009d        orderer-peer                                                                             \"orderer\"                7 minutes ago       Up 7 minutes        0.0.0.0:7050-\u003e7050/tcp                                orderer0\n0de13cd1ba31        shop-ca                                                                                  \"fabric-ca-server st…\"   7 minutes ago       Up 7 minutes        0.0.0.0:7054-\u003e7054/tcp                                shop-ca\n9dba93e63b5c        ishangulhane/fabric-couchdb                                                              \"tini -- /docker-ent…\"   7 minutes ago       Up 7 minutes        4369/tcp, 9100/tcp, 0.0.0.0:8984-\u003e5984/tcp            fitcoin-statedb\n```\n\n**Command**\n```bash\ndocker logs fitcoin_fitcoin-backend_1\n```\n**Output:**\n```\nCA registration complete\nCA registration complete\nCA registration complete\n[x] Awaiting RPC requests on clientClient0\n[x] Awaiting RPC requests on clientClient2\n[x] Awaiting RPC requests on clientClient1\n```\n\n**Command**\n```bash\ndocker logs fitcoin_shop-backend_1\n```\n**Output:**\n```\nCA registration complete\nCA registration complete\nStarting socker server\n[x] Awaiting RPC requests on clientClient0\n```\n\n## 3. Test the BlockchainNetwork\n\nIn a separate terminal navigate to testApplication folder and run the following command:\n```\nnpm install\nnode index.js\n```\nNavigate to url to view the blockchain blocks: **http://localhost:8000/history.html**\n\n![Blocks](images/blocks.png)\n\nNow navigate to url to perform operations on network : **http://localhost:8000/test.html**\n\n\u003eNote : For this application the user queue value can be either : user_queue or seller_queue\n\n**Sample Enroll User request**\n\n![Blocks](images/enroll.png)\n\n**Sample Query request**\n\n![Blocks](images/query_user.png)\n\n**Sample Invoke request**\n\n![Blocks](images/invoke_user.png)\n\n## Additional Resources\n\n* [Hyperledger Fabric Docs](https://hyperledger-fabric.readthedocs.io/en/latest/)\n* [Hyperledger Composer Docs](https://hyperledger.github.io/composer/latest/introduction/introduction.html)\n\n## License\n\nThis code pattern is licensed under the Apache Software License, Version 2.  Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the [Developer Certificate of Origin, Version 1.1 (DCO)](https://developercertificate.org/) and the [Apache Software License, Version 2](https://www.apache.org/licenses/LICENSE-2.0.txt).\n\n[Apache Software License (ASL) FAQ](https://www.apache.org/foundation/license-faq.html#WhatDoesItMEAN)\n\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIBM%2FLeveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIBM%2FLeveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIBM%2FLeveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork/lists"}