I created a WebService that runs a algorithm that takes 15 minutes running. The algorithm returns a result (JSON).
Because of the result, I am using a thread "Future Task". After I deploy the application, when I run, it returns me the correct value.
Then I run the algorithm again without restarting the Glassfish and the result is the old. How can I solve this?
Code:
@Produces(MediaType.APPLICATION_JSON)
@Path("getValues")
public String getValuesAlgorithm() throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
Future <String> future = executor.submit(new Task());
String result = future.get();
executor.shutdown();
return result;
}
class Task implements Callable<String> {
//algorithm is executed here...
return result;
}
Thanks