Axon - MessageHandlerInterceptor / 调用后的处理程序
Axon - MessageHandlerInterceptor / handler after invocations
根据文档:"A MessageHandlerInterceptor can add customized behavior to message handler invocations, both before and after the invocation"。
仅在处理程序调用工作之前(处理方法)。
如何在我的事件处理器 class 上使用它来拦截调用 @EventHandler 方法调用 (@处理组)?
我正在使用 Axon 4.3.1。
谢谢。
实现MessageHandlerInterceptor
时,需要实现以下方法:
Object handle(
UnitOfWork<? extends T> unitOfWork,
InterceptorChain interceptorChain
) throws Exception;
在消息处理前后调用操作的关键是何时您与InterceptorChain
交互。
在这种情况下,InterceptorChain
代表 MessageHandlerInterceptor
实例链。因此,调用 interceptorChain.proceed()
将告诉链移动到下一个拦截器。如果到达链的末端,Axon 将移至您自己编写的消息处理函数。
因此,在 之后执行工作 interceptorChain.proceed()
意味着您在注释方法调用之后执行工作。
您可以在 LoggingInterceptor
中看到 Axon 自己是如何做到这一点的,您可以在 here.
中找到它
根据文档:"A MessageHandlerInterceptor can add customized behavior to message handler invocations, both before and after the invocation"。
仅在处理程序调用工作之前(处理方法)。
如何在我的事件处理器 class 上使用它来拦截调用 @EventHandler 方法调用 (@处理组)?
我正在使用 Axon 4.3.1。
谢谢。
实现MessageHandlerInterceptor
时,需要实现以下方法:
Object handle(
UnitOfWork<? extends T> unitOfWork,
InterceptorChain interceptorChain
) throws Exception;
在消息处理前后调用操作的关键是何时您与InterceptorChain
交互。
在这种情况下,InterceptorChain
代表 MessageHandlerInterceptor
实例链。因此,调用 interceptorChain.proceed()
将告诉链移动到下一个拦截器。如果到达链的末端,Axon 将移至您自己编写的消息处理函数。
因此,在 之后执行工作 interceptorChain.proceed()
意味着您在注释方法调用之后执行工作。
您可以在 LoggingInterceptor
中看到 Axon 自己是如何做到这一点的,您可以在 here.