Hi Rohan,
There are multiple implementation techniques for addressing this issue.
Using OOTB: Example: Allow the VSI to return one of three responses for a given request:
- Let's assume that your specific transaction in the VSI has several responses (1 of 3, 2 of 3, 3 of 3)
- If you CLICK on the META transaction and look in the Transaction Basics (upper right) portion of the screen, you will see a Check Box for Allow Duplicate Specific transactions
- If you enable allow duplicate specific transactions, the VSI will return the 1st response the first time the service image matches this response, the 2nd response the second time the txn matches and the 3rd on the 3rd, etc. etc. The Service Image response will 'start over' once all three responses, in this example, are sent.
- Each response can have its own Think Time setting and the service (VSM) will honor that think time unless you override the Think Scale in the Server Console.
- The responses are sent serially not randomly. Stop/start the service to 'reset' the order back to the 1st, then 2nd, then 3rd, etc.
Custom:
You can enhance both the Service Model and Service Image using various techniques. Following is a description of just one way to do this.
Example uses the same three responses above except that this example will programmatically control when a given response is selected based on the generation of a random number between 0 and 100:
Service Image (VSI):
- Make 2 of the 3 responses specific transactions, and leave 1 (the most common response) as META for the Operation
- Rather than having one specific transaction with 3 responses, your Service Image now contains 1 META and 2 specific transactions each having 1 response
- You need to identify an argument on the request for this operation that can act as a tie breaker to identify the proper response. Assume you need to add an argument that does not exist on the incoming request.
- In the Service Image, editor add an argument (let's call it lisaCustomField). When you do this, your incoming request knows nothing about lisaCustomField, so you have to add code in the Service Model to add this argument and a value.
Service Model (VSM):
- In this example, we will use the LISTEN Step and add a Scriptable DPH after the SOAP filter. The Scriptable DPH will create the argument and set its value for each incoming request, or only when the request meets some specific requirement.
For example:
import com.itko.util.ParameterList;
// get the request argument list parsed by soap dph
ParameterList args = lisa_vse_request.getArguments();
// Checking for operation match, otherwise this argument will be added to every incoming request regardless of operation
if ("yourOperationName".equals(lisa_vse_request.getOperation() )
{
// add your logic here to determine which response you want selected.
// set a value in the custom argument to help you identify your specific response
// for example using a random number, you could do this
int randomNumber = (new Random()).nextInt(101);
if (randomNumber < 51)
args.addParameters("lisaCustomField=10s"); // 0 to 50 will send META
else if (randomNumber < 81)
args.addParameters("lisaCustomField=30s"); // 50 to 80 will send 30 second Think
else
args.addParameters("lisaCustomField=45s"); // 81 to 100 will send 45 second Think
}
NOTE: No syntax check applied to the above. The code is just representative of what you might do.
Back in the Service Image (VSI):
The specific txns in the VSI (for the Operation) must cater for this new field (to prevent Service Image mismatches)
The request argument name (lisaCustomField) must match the value you used in the Scriptable
Also set up the Comparison Operator and Comparison Value. For example:
Specific Txn 1 incoming arguments and their comparisons plus lisaCustomField Comparison Method (equal) Value (30s)
Modify the Response Think Time to 30000 ms (or 30 seconds)
Specific Txn 2 incoming arguments and their comparisons plus lisaCustomField Comparison Method (equal) Vakye (45s)
Modify the Response Think Time set to 45000 ms (or 45 seconds)
META Meta response just change the Think Time to what ever value you want
Kind Regards,
Joel