Announcement Announcement Module
Collapse
No announcement yet.
MDC and Spring Integration mutually exclusive? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MDC and Spring Integration mutually exclusive?

    If you want to configure your logging using the parameters set in de MDC this creates problems using Spring Integration. Because if I understand correctly MDC are threadlocal. However one of the major advantages of Spring Integration is that using the Channels the different parts dealing with the treatment can occur in different threads in the pool of threads.
    So do you have to set and unset the MDC in each component, if you want the use the executor framework. I know that MDC was intended for Servlets were every request is treated in a single thread, but it would be nice to do the same kind of thing in Spring Integration.

  • #2
    Hi

    As I understand, you would like to have MDC funcionality to log some Message-related properties as a "context" in Log4J/Logback (I suggest looking at the second solution).

    With threads it's easy - JVM gives us special thread-local storage. In Spring-Int however I can't think of an analogous message-storage other than explicit message headers. Thread-local storage is the only way to pass some data along the (e.g. log.info()) invocation if you don't want to pass Message object to every Log4J invocation.

    So I think the only way is to provide a wrapper for logging-library with methods which require a Message as first parameter.

    Or there is a better solution to this problem? Maybe someone knows?

    Grzegorz Grzybek

    Comment

    Working...
    X