Spring Boot应用程序与@Async进程挂起

时间:2018-09-25 15:03:07

标签: spring spring-boot asynchronous process

这是代码段。一旦我重新启动应用程序,该应用程序将开始运行,但是20至30分钟后,该应用程序将再次挂起。

-服务等级

if (this.Action.InvokeRequired)
        {
            StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(Massage);
            this.Invoke(d, new object[] { massage, button });
        }

日志:

@Async("defaultExecutor")
  public void process(Request req) {
    /// application logic

}


@Configuration
@EnableAsync
public class AsyncConfiguration implements AsyncConfigurer {

  @Bean("defaultExecutor")
  public Executor getAsyncExecutor() {        

    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(5);
    executor.setMaxPoolSize(10);
    executor.setQueueCapacity(20);
    executor.setRejectedExecutionHandler(new 
    ThreadPoolExecutor.CallerRunsPolicy());
    executor.setWaitForTasksToCompleteOnShutdown(true);        
    executor.initialize();
    return executor;
  }

}        

This app will run as an async process and updates the database and sends notifications.

0 个答案:

没有答案