HI Vinay
Your requirement could be met with a simple SCRIPTED Assertion as shown
below.
*import com.itko.lisa.vse.SharedModelMap;import
java.util.concurrent.atomic.AtomicInteger;_logger.info
<http: logger.info>("******INSTANCE is " + testExec.getInstance()+"
Staging ID=" +
testExec.getStagingUniqueId());if(SharedModelMap.containsKey(testExec.getStagingUniqueId(),"hit_count")){
AtomicInteger ai1 =
(AtomicInteger)SharedModelMap.getObject(testExec.getStagingUniqueId(),"hit_count");
_logger.info <http: logger.info>("Shared Model Map has hit_count alredy
defined. Hit Count=ai1"+
ai1.incrementAndGet());if(ai1.get()>=Integer.parseInt(testExec.getStateValue("maxLimit")))
{ _logger.info <http: logger.info>("Reached MAX LIMIT Quitting"+
ai1.get());return true;}}else{ _logger.info <http: logger.info>("Shared
Model Map Doesnt have hit_count. Defining it");
SharedModelMap.putObject(testExec.getStagingUniqueId(),"hit_count",new
AtomicInteger(0));}return false;*
Please add the Assertion to the Http/s Listen Step (Assuming you have a
HTTP Based VS as shown below:
[image: image.png]
With this script in place, the Virtual Service responds fine for the first
N requests (configured by property maxLimit in project config).
Once the number of transactions served by the VS crosses N, further
requests are ignored even though the VS stays in running state. The admin
has to intervene and Stop/Start the VS for the counter to be reset.
[image: image.png]
Please extend the idea to suit your specific requirements. You may consider
using APIs to shutdown the VS once it reaches the Threshold. You could even
send a custom HTTP Response once the threshold reaches.
The MAR file has been attached for your reference.
Please let me know if you have any questions. Happy to help.
--
regards
Sankar Natarajan
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
Original Message:
Sent: 3/24/2025 2:17:00 PM
From: Vinay
Subject: RE: Virtual Service to auto stop after reaching 500 calls
Thank you Sankar.
Either works for me, where I can make service to shutdown or stop listening to further requests until cleared off calls or restart the service.
Since it is with 500 calls, the capaity would be at 1 thread.
thanks
Vinay
Original Message:
Sent: Mar 24, 2025 01:56 PM
From: Sankar Natarajan
Subject: Virtual Service to auto stop after reaching 500 calls
HI Vinay
Some amount of scripting becomes essential to achieve this
requirement. May i know what would be the capacity of the VS ?
At the end of reaching the target number of requests, do you want the VS to
be shutdown or stay in running state but stop listening/Responding ?
--
regards
Sankar Natarajan
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
Original Message:
Sent: 3/24/2025 12:58:00 PM
From: Vinay
Subject: Virtual Service to auto stop after reaching 500 calls
One of the virtual service needs to be stopped after it has reached 300/500 calls.
How can we achieve this without much of coding intervention.
thanks
Vinay
</http:></http:></http:></http:>