您知道记录springwebflux控制器端点性能以保持React性的良好实践吗?下面的原则似乎不起作用,因为它会阻止io,因为proceedingjoinpoint不返回publisher<>,它只返回一个对象
@Aspect
@Component
@Slf4j
public class LoggingAspect
{
//AOP expression for which methods shall be intercepted
@Around("execution(* com.company.service..*(..)))")
public Object profileAllMethods(ProceedingJoinPoint proceedingJoinPoint) throws Throwable
{
MethodSignature methodSignature = (MethodSignature) proceedingJoinPoint.getSignature();
//Get intercepted method details
String className = methodSignature.getDeclaringType().getSimpleName();
String methodName = methodSignature.getName();
final StopWatch stopWatch = new StopWatch();
//Measure method execution time
stopWatch.start();
Object result = proceedingJoinPoint.proceed();
stopWatch.stop();
//Log method execution time
log.info("Execution time of " + className + "." + methodName + " :: " + stopWatch.getTotalTimeMillis() + " ms");
return result;
}
}
1条答案
按热度按时间ioekq8ef1#
实际上正如在评论中提到的@toerktumlare
proceedingJoinPoint.proceed()
返回对象的类型无论控制器端点返回类型是什么,因此可以保持被动的性质。注意.subscribeOn(Schedulers.parallel())
在这里是可选的,这是为了让我的后台代码支持并行性。为此发布解决方案: