Hi,
We wanted to have a service that is able to invoke another service in a different thread. we we’re able to make use of the Service.doThreadInvoke(), but upon implementation with our use case. the java service seems to mix combine the output of some of the threads.
Ideal:
output[0]: [0,1,2,3,4,5]
output[1]: [11,22,33,44,55]
Actual output:
output[0]:
output[1]: [0,1,2,3,4,5,11,22,33,44,55]
Use case:
We wanted to have a service that could spawn new threads to invoke a different service.
Input: a string array - each string of the array is the input to the service that would be invoked.
Service: a single service that accept a string. A concurrent invocation to this thread would improve the service performance as doing it synchronously. (an array of 100 string would mean to wait for the service will be invoked 100x synchronously, this would take much time.)
Output: a document array of the responses of the invoked service.
sample code snippet
for(int i = 0; i < inputStringList.length; i++){
// Create Input IData to 'getSampleDetails'
IData input = IDataFactory.create();
IDataCursor inputCursor = input.getCursor();
IDataUtil.put( inputCursor, "inputStringList", inputStringList[i] );
inputCursor.destroy();
//Invoke service
svcThread[i] = Service.doThreadInvoke("wm.test.services", "getSampleDetails", input);
}
//Get 'getSampleDetails' service output
IDataCursor pipeline_1 = pipeline.getCursor();
IData[] results = new IData[svcThread.length];
for(int i = 0; i < svcThread.length; i++){
try {
results[i] = svcThread[i].getIData();
} catch (Exception e) {throw new ServiceException(e);}
}
#Integration-Server-and-ESB#Flow-and-Java-services#webMethods