简体   繁体   English

Google App Engine是否支持使用Spring @Async?

[英]Does Google App Engine support using Spring @Async?

I have an @Api annotated Endpoint class in a Google App Engine project. 我在Google App Engine项目中有一个@Api注释的Endpoint类。 I am trying to call from a method inside this endpoint, a method annotated with @Async (org.springframework.scheduling.annotation.Async). 我试图从此端点内的方法调用,该方法使用@Async(org.springframework.scheduling.annotation.Async)注释。 When I debug in the SimpleAsyncUncaughtExceptionHandler class, handleUncaughtException method: 当我在SimpleAsyncUncaughtExceptionHandler类中调试handleUncaughtException方法时:

@Override
public void handleUncaughtException(Throwable ex, Method method, Object... params) {
    if (logger.isErrorEnabled()) {
        logger.error(String.format("Unexpected error occurred invoking async " +
                "method '%s'.", method), ex);
    }
}

The logger.isErrorEnabled() returns false and the method invoke of AsyncExecutionInterceptor returns with null. logger.isErrorEnabled()返回false, AsyncExecutionInterceptor的方法invoke返回null。 So, my question is, does GAE support using Spring's @Async functionality? 所以,我的问题是,GAE是否支持使用Spring的@Async功能?

The Gooogle AppEngine (Standard) will not support the Multiple Threads, It runs on Single Thread If you use @Async Annotation usually it will create another thread and execute and in case of AppEngine it will not create the thread and it will not execute. Gooogle AppEngine(标准版)不支持多线程,它在单线程上运行如果您使用@Async Annotation,它通常会创建另一个线程并执行,在AppEngine的情况下,它不会创建线程,也不会执行。

If you want to use the threads in Google AppEngine you still can use the Flexible version of Google AppEngine. 如果您想使用Google AppEngine中的主题,您仍然可以使用灵活版Google AppEngine。 which more like computer engine so it don't have many restrictions. 它更像是计算机引擎所以没有太多限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM