1

I am using Spring AOP and trying to intercept the different methods that are being called for a particular user operation. I am using NDC(nested diagnostic context) for this purpose. It is a multi-threaded environment, so I need to pass the NDC context from one thread to another in the @Before method of Spring AOP.

The NDC.cloneStack() and NDC.inherit() methods can be used in case I was making changes to the original program. But I am trying to do this from the @Before method which is called before each method of the program.

Is there any way to do this?

  • That will not work. The `@Before` method is already executed with the new thread and as such the NDC isn't available anymore. You would need to copy the information before you start a new thread or schedule the task. – M. Deinum Oct 13 '14 at 10:27
  • Even I am facing same issue. It would be very helpful if you can suggest a work-around @M.Deinum. – Akshay Oct 15 '14 at 07:16

0 Answers0