After my research and discussion here I decided I need to set the same name for threads on different JVMs which belong to the same control flow in the distributed system. Threads are created e.g. by RMI. Is it possible to set name when thread is created in that way?
Share
There’s no automatic means to transfer this info from client-to-server.
It sounds like you want/need some sort of
Contextobject set up on the client (per-thread?) and passed as a method argument to your RMI servers. ThatContextobject could contain not just the thread-name, but perhaps also other info like the calling process pid etc.You’d then have to use that
Contextobject to set thread-names etc. accordingly viaThread.setName()once it’s been passed across the wire. Going forwards, you could set up context-specific info in your logging framework using this (e.g. using Log4j nested diagnostic contexts)The use of aspects to automate this further is left as a further exercise for the reader 🙂