Gopi
Gopi

Reputation: 105

Unable to ignore the exception in Catch Exception Strategy

The below is the flow which I am trying to ignore the exception..

<flow name="demoFlow1" doc:name="demoFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:5050/demo" doc:name="HTTP"/>
    <set-payload value="#['sucess']" doc:name="Set Payload"/>
    <catch-exception-strategy when="#[!exception.causedBy(org.mule.api.registry.ResolverException)]" doc:name="Catch Exception Strategy">
        <logger message="Exception in flow" level="INFO" doc:name="Logger"/>
    </catch-exception-strategy>
</flow>

I am getting the below error

org.mule.api.construct.FlowConstructInvalidException: **Flow exception listener contains and exception strategy that doesn't handle all request, Perhaps there's an exception strategy with a when attribute set but it's not part of a catch exception strategy**
    at org.mule.construct.AbstractFlowConstruct.validateConstruct(AbstractFlowConstruct.java:286)
    at org.mule.construct.AbstractPipeline.validateConstruct(AbstractPipeline.java:227)
    at org.mule.construct.AbstractFlowConstruct$1.onTransition(AbstractFlowConstruct.java:108)
    at org.mule.construct.AbstractFlowConstruct$1.onTransition(AbstractFlowConstruct.java:103)
    at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(AbstractLifecycleManager.java:138)
    at org.mule.construct.FlowConstructLifecycleManager.fireInitialisePhase(FlowConstructLifecycleManager.java:78)
    at org.mule.construct.AbstractFlowConstruct.initialise(AbstractFlowConstruct.java:102)

Could you please help me out on this in mule 3.4.2 version?

Upvotes: 0

Views: 2714

Answers (4)

Dileep Dondapati
Dileep Dondapati

Reputation: 41

I got the same issue. Use catch exception inside Choice exception, this will work

Upvotes: 0

srikanth vaddella
srikanth vaddella

Reputation: 1

Pbris this Exception based Expression (when Condition)

when="#[!exception.causedBy(org.mule.api.registry.ResolverException)]

it has to be used only in Choice exception Strategy here where you have been writing catch-exception-strategy

<catch-exception-strategy when="#[!exception.causedBy(org.mule.api.registry.ResolverException)]" doc:name="Catch Exception Strategy"> <logger message="Exception in flow" level="INFO" doc:name="Logger"/> </catch-exception-strategy>

This block of code won't work until remove the when condition same thing would work in choice exception strategy with out removing the when condition

Take the reference from mule esb documentation

Upvotes: 0

Evangelina Martinez
Evangelina Martinez

Reputation: 31

Unfortunately I don't think it's possible to avoid the exception from being logged even though the Catch Exception Strategy is handling it. I created this JIRA in the ESB a while ago and it seems it's still open.

Upvotes: 0

Avanaur
Avanaur

Reputation: 475

Use a choice exception instead, then put that catch exception inside.

<flow name="demoFlow1" doc:name="demoFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:5050/demo" doc:name="HTTP"/>
    <set-payload value="#['sucess']" doc:name="Set Payload"/>
    <choice-exception-strategy doc:name="Choice Exception Strategy">
         <catch-exception-strategy when="#[!exception.causedBy(org.mule.api.registry.ResolverException)]" doc:name="Catch Exception Strategy">
             <logger message="Exception in flow" level="INFO" doc:name="Logger"/>
         </catch-exception-strategy>
    </choice-exception-strategy>
</flow>

Not sure if you would need a generic catch exception, but the above works at 3.6. If in case, do this below (with generic catch exception - no 'when' attribute)

<flow name="demoFlow1" doc:name="demoFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:5050/demo" doc:name="HTTP"/>
    <set-payload value="#['sucess']" doc:name="Set Payload"/>
    <choice-exception-strategy doc:name="Choice Exception Strategy">
         <catch-exception-strategy when="#[!exception.causedBy(org.mule.api.registry.ResolverException)]" doc:name="Catch Exception Strategy">
             <logger message="Exception in flow" level="INFO" doc:name="Logger"/>
         </catch-exception-strategy>
         <catch-exception-strategy doc:name="Catch Exception Strategy">
             <logger message="Exception in flow" level="INFO" doc:name="Logger"/>
         </catch-exception-strategy>
    </choice-exception-strategy>
</flow>

Upvotes: 1

Related Questions