我需要在taskdecorator中找出@async方法名。如何从taskdecorator中找出方法名(asyncmethodwithreturntype),或者有更好的方法找出在SpringBoot2中用@async注解的实际方法?
@Bean(name = "threadPoolTaskExecutor")
public Executor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor th = new ThreadPoolTaskExecutor();
// HERE AUDIT WOULD collect metric about method name.
th.setTaskDecorator(runnable -> AuditWrapper.auditWrapper(runnable))
}
@Async
public Future<String> asyncMethodWithReturnType() {
System.out.println("Execute method asynchronously - "
+ Thread.currentThread().getName());
try {
Thread.sleep(5000);
return new AsyncResult<String>("hello world !!!!");
} catch (InterruptedException e) {
//
}
return null;
}
请让我知道,如果你有任何更好的建议,以找出实际的方法正在执行。我需要收集方法名称以用于审核/模拟目的。
暂无答案!
目前还没有任何答案,快来回答吧!