Spring 4.2.5 Java 7 Tomcat 7Spring Асинхронный Task работает
Я хочу, чтобы проверить мой ход асинхронной задачи. Проверяйте задачу выполнения при запуске. Контроллер в качестве задачи async для запуска. hello.jsp содержит функцию jQuery (таймер), чтобы увидеть службу выполнения (itRunning).
Контроллер
@Controller
public class HelloController {
@Inject
private RouteService routeService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String printRoute() {
try {
Future<Plane> plane = routeService.execute();
} catch (Exception e) {
System.out.println(e.getMessage());
}
return "hello";
}
@RequestMapping(value = "/status")
@ResponseBody
public String fetchStatus() {
--> Here return itRunning
}
}
Сервис
@Component("routeService")
public class RouteService {
@Inject
private Route route;
@Async
public Future<Plane> execute() {
Plane plane = route.execute();
return new AsyncResult<Plane>(boat);
}
}
AsyncTask
public class Route
{
private int itRunning=0;
public Plane execute() {
itRunning++;
}
public int getItRunning() {
return itRunning;
}
}
Как я могу прочитать itRunning?
Thanks