1 Reply Latest reply on Mar 30, 2011 9:45 AM by sabre150

    Java 6 RMI thread naming strategy question.

      Sorry if this has been covered, but nothing obvious is showing up in my searches...

      We have a series of heavily utilized RMI/IIOP servers that traditionally have been running under Java 5.

      Under Java 5 the RMI threads would have names (as reported by log4j) such as "p: default-threadpool; w: 896" in which we would use to track a methods logging statements throughout the execution of a given call.

      Of course, these server methods would execute concurrently, so having that worker id was useful, especially if things went badly.

      Well things are evolving here and we are looking to move to Java 6 and we have noticed that under Java 6 these RMI threads now all seem to have the same name regardless of the load, specifically "p: default-threadpool; w: Idle", which unfortunately breaks the ability to associate logging statements with a given call out of the box.

      Outside of renaming the threads on entry of every RMI method, is there a way to coax the Java 6 VM to revert to the earlier naming strategy?



      Edited by: user13810028 on Mar 29, 2011 8:31 AM - Typo
        • 1. Re: Java 6 RMI thread naming strategy question.
          I haven't used RMI for some time but I solved a very similar problem with RMI some time ago by utilising ThreadLocal. Each RMI method set up a ThreadLocal variable containing the name of the user, the method name and the parameter values. This TheadLocal content was then used in all logging. When a thread handed over control to a task which was placed in a queue for later execution the context in the ThreadLocal value was copied into the task and used in the logging.

          At the time I would have preferred would have been to pass this 'context' explicitly along the line but the powers that be did not want to make such an intrusive change. Were they right ? Who knows!

          Of course this approach would mean a significant change to your system.