spring jms-在收到消息之前执行操作

问题描述 投票:0回答:1

是否可以在Spring Boot中收到jms消息之前执行操作?我知道我可以将其放在@JmsListener的最上方,但是我有几个侦听器,因此我希望避免向所有听众添加呼叫。

我正在尝试使用日志记录MDC(如果您不熟悉MDC,则为本地线程)来跟踪各种情况,我想在开始处理消息之前设置一些属性。我可以使用Filter在控制器上执行此操作,但是spring jms是否具有相同的概念?

spring spring-boot spring-jms mdc
1个回答
0
投票

我将尝试从Before或Around开始(以防在处理消息后也应实现一些逻辑):

@Before("@annotation(JmsListener)")
public void handle(ProceedingJoinPoint joinPoint) { ... }

@Around("@annotation(JmsListener)")
public void handle(ProceedingJoinPoint joinPoint) { ... }

链接对:enabling aspectj supportbefore advicearound advice

© www.soinside.com 2019 - 2024. All rights reserved.