I have a Data61Bpmn2Chaincode application (https://github.com/leoaction/Data61BPMNtoChaincode).
With this its possible to execute bpmn processes running on a camunda engine (local on port 8081, 8082, 8083) - depending on how many participants are acting within the bpmn process there is one engine per participant.
I have a nodeJS hyperledger fabric api (port 3000) which can handle post routes to the chaincode peers to executed either invoke or query requests by setting docker requests to the peers on the network.
Then i have a third "server" called RO which is a node JS application looking with follow package at the associated couchDB for chaincode for changes.
So, I write a dataobject means i make a request from BPMN to the nodeJS hyperledger API with a function name (corresponds to the activity name of BPMN process), a variable name and a value. The nodeJS hyperledger api recognizes it as a invoke request and updates the state from the ledger.
Invoke request:
obj = shell.exec("docker exec -t " + orgName + "_" + unique_id + "_cli peer chaincode invoke --waitForEvent -o orderer." + orgDomain + ":7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/" + orgDomain + "/orderers/orderer."+ orgDomain + "/msp/tlscacerts/tlsca." + orgDomain + "-cert.pem -C " + channelName + " -n " + sessionId + " -c '{\"Args\":[\"" + actionName + "\"" + paramString + "]}'", {silent:true});
docker exec -t Lane1_2rzP7p_cli peer chaincode invoke --waitForEvent -o orderer.2rzP7p.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/2rzP7p.com/orderers/orderer.2rzP7p.com/msp/tlscacerts/tlsca.2rzP7p.com-cert.pem -C mychannel -n 4a783da9-8fe3-4312-aef2-7d3e1468fb67 -c '{"Args":["BRT1 [P1]", "true", "exclusiveGateway_3_split_decision"]}'
Next, the RO server see the changes on the ledger and sends a request to the hyperledger API, but this time its a query request. Getting the value of the variable Name (exclusiveGateway_3_split_decision) which has changed.
This works very fine when I execute this manually, I can simply query each stored document on the couchDB by its name.
The request:
obj = shell.exec("docker exec -t " + orgName + "_" + unique_id + "_cli peer chaincode query -C " + channelName + " -n " + sessionId + " -c '{\"Args\":[\"" + "get" + "\"" + paramString + "]}'", {silent:true})
Executed chaincode get method:
value, err := stub.GetState(args[0])
if err != nil {
fmt.Printf("get err %s\\n", err)
return shim.Error(err.Error())
}
Everything works fine when i executed it manually with postman (because there it is enough time for the chain to transmit everything before a next request comes) but when i executed multiple processes which are all making invoke and query requests to the chain with the camunda engine sending automatically requests, I have the curious problem of receiving a response which is actually not for this participant.
So somehow the requests or responses are overlapping? I thought, that each request gets executed sequentially on the chain so i do not need to take care of whether invoke or query requests are happing in which point of time.
What I suspect is that the query request gets somehow executed twice because, the first time it delivers the value and also the response to the right caller, but somehow it gets executed a second time and then it throws an error that he cannot identifiy the function name called (as i do not have a function name on query request only on invoking) this seems to somehow gets overtaken from the last invoke request. The caller of invoke request now gets this error back cannot identify function name.
But i see in the logs that the function from the called invoke request has already been executed, logged and is done, but he hasnt got a response on that, the response he receives is the found error.
I know without seeing the whole project its hard, but such a weired behaviour is not normal so what would you think could cause this problem, and what can i do?
Thanks for any advice.