Forum Discussion

eniss's avatar
eniss
New Contributor
11 years ago

Context Issue in Multithreading MockService Response

Hi everyone !

I'm working on SoapUI to test mock services with Groovy scripts. My mocks works fine in single-thread mode (only one execution at a time), but when I launch multithreaded mocks, responses from the mock are wrong (eg the second response takes the value of the first) because of concurrency in treatment of the mocks. This is due to the context in which I store the answers retrieved from a query.

My XML response :
<item> ${id} </ item>


My groovy script:
 
groovyUtils def = new com.eviware.soapui.support.GroovyUtils (context)
def holder = groovyUtils.getXmlHolder (mockRequest.requestContent)
 
cstmt con.prepareCall def = ("{CALL STORED_PROCEDURE_X (,,)??}");
/ / parameters declaration of the procedure ...
 
cstmt.executeQuery def rs = ();
 
/ / Retrieve the response parameters
if (rs.next ())
 {
   context.id = rs.getString ("id");
 }


I saw this thread and tried to lock the context as the following :
context.lock = new Object();

synchronized(context.lock)
{
context.id = rs1.getString("id");
}


But it didn't work. How can I lock the context to avoid the concurrency exception ? Someone would have an idea how to solve this problem ?

Thanks in advance.
No RepliesBe the first to reply