Installable cloud operations perform all database operations in transactions. Each transaction is assigned with a unique transaction ID. An existing transaction ID will become invalid if any of the following cases occur:
-
When the relevant session ID becomes invalid;
-
At the execution of Connect, Disconnect, Commit, or Rollback.
When the Connect, Disconnect, Commit or Rollback is executed, the response body will contain the new transaction ID. When the Commit or Rollback is executed but has failed, the response body will still contain the old transaction ID, which means that the old transaction is still valid.
It is necessary to catch the proper "transactionid" from the server response on Connect/Disconnect/Commit/Rollback, and then attach it to the subsequent requests. That is, correlating the transaction ID in the script for successful replay.
The following steps take the Connect request as an example, and the session ID has already been correlated.
-
Add scripts in the Connect for capturing the transaction ID and assign it to a parameter.
A ConnectAndCreateTransaction request looks like the following:
web_custom_request("ConnectAndCreateTransaction", "URL=http://172.16.9.79:5099/api/ServerApi/ConnectAndCreateTransaction", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t65.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"header\":[\"2.0\",7,\"psapi4loadrunner_cloud\",\"Psapi4loadrunner_cloud\",\"" "<gs_SessionID>\",\"\",\"sqlca\"],\"content\":{\"cachegroup\":\"\",\"" "cachename\":\"\",\"transactionname\":\"sqlca\",\"params\":\"eyJ0aW1lc3RhbXAiOjE2NTk4ODM1NjYsInBheWxvYWQiOiJidWx1VkxDdWJMa1NCWUpkejZuUVMvdU5KdFJyT1gyeXU2RC8yRjcxdlNRRllvVlZQQitiYS9qMGhVQkgwY3dEblo2d3Y3N2ZZVUl3VEF0OWlGc2NaZEl5TGg2M3MrOXc4Q3h5bWZRaTJFaDdaNGZnd0dWUmdabkdUUGFaQWY2MSIsInNpZ25hdHVyZSI6InM4L0VKQXhTdWZmckt3M3FsVGxzcTNIQXdmek5MLzZaM3NjOXdlUDcxM1FScTdoUFRpbmZaVmRTby94T3kzUFNWVldBUUUvMzdRcHg2ejBsTEZLajVBPT0ifQ==\"}}", LAST);
You need to add the following code above the ConnectAndCreateTransaction request:
-
Add a web_reg_save_param function above the request to capture the transaction ID and assign it to the parameter "gs_TransactionID".
web_reg_save_param("gs_TransactionID", "LB=\",7,0,null,\"", "RB=\",0,0,null,null],\"content", "Search=Body", LAST);
-
-
Replace the transaction ID with the parameter every time it occurs.
-
Identify the transaction ID that needs to be correlated. You may do a global search in the script for "transactionid" which is followed by the transaction ID. Ensure that there is no confusion between the current transaction ID and the other ones.
-
Replace every occurrence of the transaction ID with the parameter <gs_TransactionID>.
web_custom_request("RetrieveWithParm", "URL=http://172.16.9.79:5099/api/ServerApi/RetrieveWithParm", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t68.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"header\":[\"2.0\",1,\"psapi4loadrunner_cloud\",\"Psapi4loadrunner_cloud\",\"<gs_SessionID>\"" ",\"<gs_TransactionID>\",\"sqlca\"],\"content\":{\"retrieves\":[{\"properties\":[\"E6C045DD-0D47-4de2-858C-FC65752080A2\",\"\",\"d_customers\",\"\",false,false,\"\",\"\",1],\"arguments\":[]}]}}", LAST);
-
If your application has multiple transactions, each transaction has its unique transaction ID. The transactions can be differentiated by their transaction names, and their transaction IDs shall be assigned with different parameters, so that each parameter will correlate with its own transaction.
-
Add scripts in the Connect for capturing the transaction ID and assign it to a parameter.
A ConnectAndCreateTransaction request in a transaction named "n_trans_rpc" looks like the following:
web_custom_request("ConnectAndCreateTransaction_2", "URL=http://172.16.9.79:5099/api/ServerApi/ConnectAndCreateTransaction", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t47.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"header\":[\"2.0\",7,\"psapi4loadrunner_cloud\",\"Psapi4loadrunner_cloud\",\"" "eyJ0aW1lc3RhbXAiOjE2NTk5Mzk5NzEsInBheWxvYWQiOiJGZEJaOVlCdG8vRERpRmlhaW9PdXNGYVA1WjZ1TFl3dXRXZE9iMkd6dmhETEZRcnp0L3hnbDdIWStMTkhaRDNzSFVGM0IyYmJVZWhwUWhTZ2VmSUVIeGZFS2p5WUNxaTNxOEhkTXNqdDJNaDVoOGdkcityUXVFbUd2TzRLN1hvRm8rSUVUejBBU3pybWFia0d4eTlEUGNHdUNJNjRUeXZnbDNJSTZFRHJzMkVWZnBKczgyT1dWYm84UncyQU1Ibm4iLCJzaWduYXR1cmUiOiJ2QmxZRTgxcGdWejdqNVNHTWtSMUp0My9XNzJoK09aMzBndU10aWxCcUNlU1h4cXU2V05IRzFRdDV3M0Z3cStpejh3ODdYakttbXdtVVhuMHg0c3p2UT09In0=\",\"\",\"n_trans_rpc\"],\"content\":{\"cachegroup\":\"\"," "\"cachename\":\"\",\"transactionname\":\"n_trans_rpc\",\"params\":\"eyJ0aW1lc3RhbXAiOjE2NTk5Mzk5NzEsInBheWxvYWQiOiI0MlIrdEl3TnFlTlRIRnBnRmRqVzZ6OFlPK2RjbVpUUlJQNXdSY0FHMG02aytQVW45TGVlMGs3NWZwcUoxM256RW9xYzJsMC8vUk9NY2h0YitkSVRWU1hYTzhRb1hSRnBxYlRCekh5QXY4SExyZDF5WUU2b2tCZEpaL210QnJ2ViIsInNpZ25hdHVyZSI6IkU5YVVKK1NNQTB2aC91dThLc251c3BNU1c5ZXY5SXlVRktFUUVnc3BKVkdMc1VxcWlrUjJQdkp6WiszbnJWSktWRi8vMmlPeDZmcy9OUjVHNnFmOVZBPT0ifQ==\"}}", LAST);
You need to add the following code above the ConnectAndCreateTransaction request:
-
Add a web_reg_save_param function above the request to capture the transaction ID and assign it to the parameter "gs_TransactionID2".
web_reg_save_param("gs_TransactionID2", "LB=\",7,0,null,\"", "RB=\",0,0,null,null],\"content", "Search=Body", LAST);
-
-
Replace the transaction ID with the parameter every time it occurs.
-
Identify the transaction ID that needs to be correlated. You may do a global search in the script for the transaction name "n_trans_rpc" which follows the transaction ID.
-
Replace every occurrence of the transaction ID with the parameter <gs_TransactionID2>.
web_custom_request("RpcFunction", "URL=http://172.16.9.79:5099/api/ServerApi/RpcFunction", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t48.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"header\":[\"2.0\",29,\"psapi4loadrunner_cloud\",\"Psapi4loadrunner_cloud\",\"eyJ0aW1lc3RhbXAiOjE2NTk5Mzk5NzEsInBheWxvYWQiOiJGZEJaOVlCdG8vRERpRmlhaW9PdXNGYVA1WjZ1TFl3dXRXZE9iMkd6dmhETEZRcnp0L3hnbDdIWStMTkhaRDNzSFVGM0IyYmJVZWhwUWhTZ2VmSUVIN1ZDUXQyNm1EdzFqamFKc3M4Z2NONmF6WkJSam4xeVUrL2FvVE9uanV2WmY4SlNEMnBVaGprNTN3Y3BqVW9oekFiWVNLSEVncXNqTTVrdi9aOHlWQTQ9Iiwic2lnbmF0dXJlIjoieFhseHNCK1pSR3BtcE9WanJaU204dFdteElpcC80UDhvM2JHck4yR3IzaXdGcnVUckttV3gyd0JxaG1aMkxIVUdoNjZVU0xnR1lUcWZrVlRrVm1mYmc9PSJ9" "\",\"86105204-1DFA-44CB-BA7D-5B1C759720C1-37\",\"<gs_TransactionID2>\"],\"content\":{\"functionname\":\"test4loadrunner\",\"parameters\":[[\"name\",2,101],[\"name\",8,\"\"]]}}", LAST);
-