In Spring Integration (and derivative projects such as Spring Cloud Stream), we have a need to add property inputMessage or originalMessage or similar to the ErrorMessage.
Typically, the payload of an ErrorMessage is a MessagingException with a failedMessage property containing the message at the point of failure.
The original message at the place in the stack where the exception is caught (and the ErrorMessage created) may be different to the message at the point of failure - it may have gone through several transformations before the exception occurs.
In certain use cases, it would be useful to have access to both messages for error handling purposes. Hence the desire to add this property.
We can (and have) create a subclass for this, but are having a hard time coming up with a good name EnhancedErrorMessage , ExtendedErrorMessage etc.
So we wish to float the idea to add it to the core ErrorMessage since it might be useful elsewhere.
If you concur, we'd be happy to issue a PR. It would be nice to have it in a 4.3.x release too, but we can live with our badly named subclass until 5.0 (or indefinitely if you don't want this in core messaging).
We don't seem to be using ErrorMessage in spring-messaging and since we do have it, you're the main driver effectively. A property such as contextMessage (or similar) on ErrorMessage sounds fine to me. What do you think Juergen Hoeller?
Gary Russell, would you mind if I changed the toString() output to an ErrorMessage [...] for original GenericMessage [...] style format, without nested braces? I've tried this locally and it looks less convoluted (and avoids the artificial shortening of the parent class toString result).