Similar to the session ID, you can use the following to correlate the transaction ID:
-
a Regular Expression Extractor that saves the transaction ID to a local variable
-
a BeanShell Sampler that calls the "setProperty" function to set the local variable as a global property, so that it can be shared in all thread groups
In the case of PowerServer, the following requests will update/change the transaction ID and contain the new ID in the response body:
-
Connect
-
DisConnect
-
Commit
-
Rollback
When Commit or Rollback failed, the response body will still contain the old transaction ID, which means the old transaction ID is still valid.
In the case of PowerServer, the Connect, DisConnect, Commit, and Rollback request will update/change the transaction ID, therefore, you need to add a Regular Expression Extractor to each of these requests to get and save the transaction ID into a variable.
Let’s take the ConnectAndCreateTransaction request as an example.
To add a Regular Expression Extractor, right click on the ConnectAndCreateTransaction request and then select Add > Post Processors > Regular Expression Extractor.
Specify the Regular Expression Extractor like this:
-
Name of created variable: "transaction" or any other name you prefer
-
Regular Expression: 9,0,null,"(.+?)",0,0,null],"content
-
Template: $1$
-
Match No.: 1
The transaction ID will be saved to the
"transaction
" variable. You can invoke the local
variable by typing ${transaction}
in the requests
(bodies and headers).
If you want to make the "transaction
" variable a
global property that can be accessed by all threads and thread
groups, you can add a BeanShell
Sampler or BeanShell
PostProcessor to call the JMeter "setProperty" function.
The "setProperty" function will set the "transaction" variable as a
global property. the section called “Modifying the scripts” has
instructions for how to add a BeanShell
PostProcessor. This section will show how to add a
BeanShell Sampler.
To add a BeanShell Sampler, right click on setUp Thread Group, and then select Add > Sampler > BeanShell Sampler.
-
Use the default name or input any name you prefer.
-
Input the following script:
${__setProperty(transaction,${transaction},)}
The "transaction
" variable can be accessed as a
JMeter global property.
Find the transaction ID in all thread groups, and replace the
value of transaction ID with
${__property(transaction,,)}
. For how to find the
transaction ID in different requests, refer to Where to find
session ID and transaction ID.
Following shows how to correlate the session ID and transaction ID in the CommitAndCreateTransaction request.
Find the value of session ID and transaction ID in the request:
Replace them with the global property
${__property(session,,)}
and
${__property(transaction,,)}
:
If your application uses multiple transactions, then each transaction will have its unique transaction ID. The transactions can be differentiated by their transaction names, and their transaction IDs shall be assigned with different variables, so that each variable will correlate with its own transaction.
Suppose your application has two transactions: SQLCA, and lstr_trans1. You will need to define two variables to store the ID of each transaction.
For transaction name "SQLCA"
-
Add a Regular Expression Extractor to store the ID of the "SQLCA" transaction to a variable. Suppose the variable name is "
transaction
". -
Add a BeanShell Sampler to call the JMeter "setProperty" function to set the variable as a global property:
${__setProperty(transaction,${transaction},)}
For transaction name "lstr_trans1"
-
Add a Regular Expression Extractor to store the ID of the "lstr_trans1" transaction to a variable. Suppose the variable name is "
trans
". -
Add a BeanShell Sampler to call the JMeter "setProperty" function to set the variable as a global property:
${__setProperty(trans,${trans},)}
Make sure to replace the transaction ID with the appropriate variable according to the transaction name. (You can use the Search menu to search for the transaction name and then replace its ID with the corresponding variable.)
After execution, you can view the View Results Tree to double check the transaction ID.
For example, in the Connect and Disconnect request pair, the transaction ID should be the same.