How do we hook into After message processing using @RabbitListener

263 views Asked by At

After checking the answer provided here (https://stackoverflow.com/a/34514526/6613150), I'm able to intercept the message before it's processed. However, I now need to get it after the method who is annotated with @RabbitListener ends.

Any idea?

1

There are 1 answers

0
Gary Russell On

Add a MethodInterceptor advice to the container's advice chain instead. That way you have access to the Message before and after the listener call (and notification of any exception thrown).

try {
    // before (message is in invocation arguments)
    invocation.proceed();
    // after
}
catch (Exception e) {
    ...
    throw e;
}
finally {
    ...
}