Hi DevTestUser,
I have added "Execute Script (JSR-223)" step in VSM and here is the groovy code I have written to get TPS details with counter mechanism. I am still working on some features to manager timer task thread properly. You can modify the code as per your need. FYI: With this code timer will be running all the time in VSE. You explicitly have to close the VSE to stop the timer.
-------------------------------------------------------------------------------------
import static Constants.*
import com.itko.lisa.vse.stateful.model.Response;
import com.itko.lisa.vse.stateful.model.TransientResponse;
import com.itko.util.Parameter;
import com.itko.util.ParameterList;
import java.util.timer.*
import java.util.TimerTask;
import com.itko.lisa.VSE;
import com.itko.lisa.test.TestExec;
class TimerTaskThread extends TimerTask {
public void run() {
if(Constants.numberOfTransactions > 0) {
VSE.info(Constants.testExecObj, "TimerTask : Transactions in Last 1 Second : ", "" + Constants.numberOfTransactions);
}
Constants.numberOfTransactions = 0;
}
}
class Constants {
static final maxTransPerSec = 5; // maximum number of connections
static numberOfTransactions = 0; // counter to maintain processed transactions
static int delay = 0 // delay for 0 sec.
static int period = 1000 // repeat every 1 sec.
static TestExec testExecObj = null; // testExec object
static Timer timer = new Timer().scheduleAtFixedRate(new TimerTaskThread(), delay, period); // timer
}
Constants.testExecObj = testExec;
synchronized(this) {
Constants.numberOfTransactions = Constants.numberOfTransactions + 1;
}
if(Constants.numberOfTransactions > Constants.maxTransPerSec) {
//Build response object
}
-------------------------------------------------------------------------------------
Thanks.