I have used a "catch exception strategy" to catch any exception that arise in the flow. Now i want to print the payload just before which the exception has araised . Is there a way to achieve this in mule?
3 Answers
Store the payload in session variable and print that in catch exception strategy.

- 367
- 3
- 9
-
Thanks for the response. My original payload has undergone some processing. Now an exception has come. So how will i be able to store this processed payload in a variable without knowing where the exception can arise? – keerthi ch Dec 04 '15 at 07:50
You can get the exception Payload from the MuleMessage using message.getExceptionPayload()
but, when an exception occurs the payload is consumed and in order to get the original payload that was before the exception you'll have to resort to the storing of payload in a variable like <set-variable variableName="originalPayload" value="#[message.payload]" />
and then access it using MEL #[flowVars.originalPayload]
after the exception has occured (or using message.getInvocationProperty("originalPayload")
if you're inside a JAVA component).
Here are some links for your reference though that'll shed more light into the topic :
https://docs.mulesoft.com/mule-user-guide/v/3.6/exception-strategy-most-common-use-cases
Why is Mule payload getting lost in <catch-exception-strategy> for java.net.ConnectException
Mule ESB - Catch Exception Strategy block and Payload
You can use session scope for the variable so that it doesn't get lost.
-Shanky G.

- 1
- 1

- 250
- 2
- 14
-
1Thanks for the response. My original payload has undergone some processing. Now an exception has come. So how will i be able to store this processed payload in a variable without knowing where the exception can arise? – keerthi ch Dec 03 '15 at 11:47
-
Sorry for the late reply. I came across Mule server notifications using which you can have listeners for certain events and even exceptions. Maybe that can help you out if you haven't found any solution for your requirement. – Shanky_Gupta Dec 20 '15 at 15:17
you can try this as follows by dragging "catch exception stratergy"
<catch-exception-strategy doc:name="Catch_Exception_Strategy">
<logger message="Exception---" level="INFO" doc:name="Logger"/>
<set-variable variableName="SetException" value="#[exception.message]" doc:name="SetException"/>
<set-payload value="#[payload]" doc:name="FailedToEvaluateTheTask"/>
</catch-exception-strategy>
Hope this helps you out!

- 127
- 1
- 7