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://192.168.178.125:5001/api/ServerApi/ConnectAndCreateTransaction", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t275.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"version\":\"1.0\",\"requestid\":\"667FF1FE-77F8-40b6-869E-EA90D466B504\", \"appname\":\"psapi4loadrunner\",\"namespace\":\"Psapi4loadrunner\",\"session\":\"" "<gs_SessionID>\",\"type\":7,\"transaction\":null,\"content\":{\"connect" "\":{\"cachegroup\":\"\",\"cachename\":\"\",\"transactionname\":\"sqlca\",\"params\":\"" "eyJ0aW1lc3RhbXAiOjE2MjUyMDM0OTMsInBheWxvYWQiOiJjNjJLb3BST1pMVVBuZVc4NXk5bUgzb1RvOXI1NSs rR05UTC90S2wyR2lubExleE1CdCtVaGttRWJtd2N2Um5vVTlBejBCbDV3Mlh0aW5zYi80SU9jQW5uc2hqNXdSbUt 0ZGx0UlJkeVllSCtEU1JTc1ZNVjd5SmttTnBTdHpoZnZHK3Z0RnhJWE1JczZHRzh5QVJsd2U1WlJ3VEFUVmIxeFF rZnl3MXdOc1ZUeFNGMDNsb2UwMlZXVU1JOUU5MzhuTHhoaXRxMElmTTZjaVhST21la2xMaEh6ZkREcm1tc3RWYVU 4OWhuY2ZZNU5oaXdtMHFnYkowY2Fsdmp6OENOcjhmVHpZR1BmQ0UxZW1YZ3lkNG8vUT09Iiwic2lnbmF0dXJlIjo idFkwVDlURUxYY0tOTEhBdmZzQUNOQ0tuRWtlRUtKNEFMSnBsamJ1aFRtYk92dU" "FhSnBrNXlLMTBhMEtiMzQ1dkc4Vm9tRTJZaG9Kb0FnbUlOaHF1cWc9PSJ9\"}}}", 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=\"transactionid\":\"","RB=\"},\"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://192.168.178.125:5001/api/ServerApi/RetrieveWithParm", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t279.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"version\":\"1.0\",\"requestid\":\"014DD22B-11AB-4238-88D1-7892060396AD\",\"appname\": \"psapi4loadrunner\",\"namespace\":\"Psapi4loadrunner\",\"session\":\"""<gs_SessionID>\", \"type\":1,\"transaction\":{\"transactionid\":\"""<gs_TransactionID>\",\"transactionname\ ":\"sqlca\"},\"content\":{\"retrieves\":[{\"retrieveid\":\"014DD22B-11AB-4238-88D1-789206 0396AD\",\"parent\":\"\",\"dataobject\":\"d_customers\",\"parentcolumn\":\"\",\"isreport\": false,\"isdynamic\":false,\"dwsyntax\":\"\",\"sql\":\"\",\"processing\":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 “itr_dynamiccon” looks like the following:
web_custom_request("ConnectAndCreateTransaction_2", "URL=http://192.168.178.125:5001/api/ServerApi/ConnectAndCreateTransaction", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t337.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"version\":\"1.0\",\"requestid\":\"5D86818C-CAF5-49fe-B78A-4AC7AC550F88\",\"appname\" :\"psapi4loadrunner\",\"namespace\":\"Psapi4loadrunner\",\"session\":\"""<gs_SessionID>\" ,\"type\":7,\"transaction\":null,\"content\":{\"connect""\":{\"cachegroup\":\"\",\"cachename\ ":\"PostgreSQL\",\"transactionname\":\"itr_dynamiccon\",\"params\":\"""eyJ0aW1lc3RhbXAiOjE2Mj UyMDg5MTEsInBheWxvYWQiOiJna21qUzVZY01RM294ZnJLVFNQQ1NyRFJuUENqTmxPTHZEeENGUlJ0MngrNW1WV3d2WFJ NK3BCalRiMEFKY05EZm5iMFU5VVQ0ckhjdnRRQ0tubkV1Q29adlhoOExlRXZvaFhsSGJlMmQ1cFdRZzc2VnhLOGYwZHZl SDBGMVRBRTB6YU9zaEhuM2lKMGZEQkJSak1scXl1MThyUnM0OFlOY3dlMGY2ZGpHbWVvUGxmVU40RzM0MTcwMCtzbUh3U ng5ZUlIcnUvR2pRS0hkYmFFRWJyMlAxR2tMZVg4UE1wVlVtZTh5ektJWlRZZUVkSFBtd3crekpLNlJFeE9QMFFKVVdIVW 4wajFKemh0MURYcW95VjlKMjJyam5CNVk3U1dBYy91UnRlQkxmUT0iLCJzaWduYXR1cmUiOiIyT2t2SGRIaWtoWGZzeXQ vSHNhSUk4R3VzQj""M5OXJmbER1YzdTWEpkNjg1bDlxUjJJbkpzRGVVbTcxdVl6WHh0UGZFeTFGTFUzcDRjRWNWK2p1YW F0UT09In0=\"}}}", 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_Dycache”. Here the parameter name has a suffix “_Dycache” to identify the transaction “itr_dynamiccon”.
web_reg_save_param("gs_TransactionID_Dycache","LB=\"transactionid\":\"","RB=\"},\"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 “itr_dynamiccon” which follows the transaction ID.
-
Replace every occurrence of the transaction ID with the parameter <gs_TransactionID_Dycache>.
web_custom_request("RetrieveWithParm", "URL=http://192.168.178.125:5001/api/ServerApi/RetrieveWithParm", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t338.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"version\":\"1.0\",\"requestid\":\"81EDB9E2-CC47-4b68-B70A-09B46DD88261\",\"appname\":\ "psapi4loadrunner\",\"namespace\":\"Psapi4loadrunner\",\"session\":\"""<gs_SessionID>\",\ "type\":1,\"transaction\":{\"transactionid\":\"""<gs_TransactionID_Dycache>\",\"transactionname\" :\"itr_dynamiccon\"},\"content\":{\"retrieves\":[{\"retrieveid\":\"81EDB9E2-CC47-4b68-B70A-09B46 DD88261\",\"parent\":\"\",\"dataobject\":\"d_customers\",\"parentcolumn\":\"\",\"isreport\":false, \"isdynamic\":false,\"dwsyntax\":\"\",\"sql\":\"\",\"processing\":1,\"arguments\":[]}]}}", LAST);
-