问题
With Mule ESB, from an arbitrary class, is it possible to get a handle of the current mule message for that thread? For example, if I create custom log4j appender, can it get access to the mule message and pull data from it?
回答1:
Yes, by using RequestContext.getEvent().getMessage()
(javadoc).
And yes, it is deprecated, with this warning:
If access to MuleEvent or MuleMessage is required, then implement a MessageProcessor or Callable instead
But this is not always possible. So using this static helper remains your best option.
来源:https://stackoverflow.com/questions/27976893/access-mule-message-from-arbitrary-place-in-a-thread