2 Replies Latest reply on Jul 27, 2012 3:05 AM by tarioch

    Correlation id accross @Asynchronous EJB calls

    tarioch

      I would like to have a constistent correlation id accross all calls from one session.

       

      The idea I had was to use the MDC and this seems to work fine for synchronous calls but not for asynchronous calls. The MDC seems to get lost when doing an asynchronous EJB call.

       

      Is there a way to make this work or maybe a better approach to do this?

       

      I'd rather not have to manually modfiy each asynchronous call to copy over the MDC information.

        • 1. Re: Correlation id accross @Asynchronous EJB calls
          jaikiran

          What exactly do you mean by a correlation id and why do you need it? How do you plan to use such an id across multiple invocations?

          • 2. Re: Correlation id accross @Asynchronous EJB calls
            tarioch

            I just want to have one id to correlate log messages originating from a web request.

             

             

            user a requests /foo.jsf

             

            there is a servlet filter that intercepts all calls and generates a unique id and sets this into the MDC

             

            logging is configured to always add this id

             

            if there is a log statement on the web side or in an ejb that is called synchronously, this works fine

             

            if there is an asynchronous invocation, the MDC context is lost and everything logged from in there does not have the unique id

             

             

            My guess is that, when jboss gets the thread from the thread pool for the asynchronous request, there is the code missing to copy over the MDC (see http://logback.qos.ch/manual/mdc.html#managedThreads)

            So I'm wondering if there is any way for me to workaround this without having to manually propagate the MDC on each asynchronous call.

             

            Btw. I opened up a defect for the lost MDC: https://issues.jboss.org/browse/AS7-5258