Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with the thread when calling third party Web service  RSS feed

 
Rakesh Am
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an issue when i call a third party web service from thread. The example code I have given below.
This code is used to process incoming file. First process method will validate the inputs. then it will do virus scan on the file. for which we have to call a third party webs service.
I am starting the thread because I have to return to caller whether file valid or not and processing is done inside the thread. I have added debug statements inside the thread and virus scan method.
It coming inside the virus scan method, but stops in between without doing virus scan.

Please anybody can help me on this issue.


public class ProcessWS {
public ProcessWS() {
}

public String process(String filename,String srno){

if (filename==null || "".equals(filename) || srno==null || "".equals(srno)){
//log input values are invalid.

return "Invalid input parameters";

}

new Thread(new MyThread(filename,srno)).start();

return "Validations done.Process is started.";


}

class MyThread implements Runnable{

String fn=null;
String srnumber = null;
MyThread(String filename, String srno){
fn = filename;
srnumber = srno;
}

public void run() {
VirusScan vs = new VirusScan();
vs.doVirusScan(fn,srnumber);
// .doVirusScan(fn,srnumber);

}
}

}


Thanks ,
Rakesh
 
Vijitha Kumara
Saloon Keeper
Posts: 3997
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakesh Am wrote:.. It coming inside the virus scan method, but stops in between without doing virus scan.

How, Any exceptions?
 
Rakesh Am
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Virus scan or virus scan method is not throwing any exceptions.

I did stand alone test on Virus scan. It worked properly. When I tried to call thru thread then only I got this issue.
 
Vijitha Kumara
Saloon Keeper
Posts: 3997
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakesh Am wrote:Virus scan or virus scan method is not throwing any exceptions.
I did stand alone test on Virus scan. It worked properly. When I tried to call thru thread then only I got this issue.

Best way to find out would be to put those debug statements inside all those method(s) (i.e: in the begining/end/middle etc..) and see up to which point it gets executed. If you done that up to which point it executes?
 
Rakesh Am
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a scenario like this:
Inside a method, I have to validate the input parameters and also need to start a process independently to do file process. This process will take 4-5 mins. So it should not impact the return value/method.

Can you suggest some ways to implement it?

 
Vijitha Kumara
Saloon Keeper
Posts: 3997
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another approach would be to use JMS ? as this looks like asynchronous communication between components. But that depends on the environment/what you are allowed to use etc..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!