ExceptionStrategy Objective:Mule application must beable to handle exceptional situations that can occur from time to time. Thisdocument will cover how to manage and work with such exceptional situations. ErrorHandling and Recovery: Choice Exception Strategy:You can define a choiceexception strategy to customize the way Mule handles a message with an errorbased on the message’s content at the moment it throws an exception. A choiceexception strategy catches all exceptions thrown within its parent flow,examines message contents and exception type, then routes messages to theappropriate exception strategy for processing.Usually, you define morethan one exception strategy within a choice exception strategy. Each exceptionstrategy – either catch or rollback – uses a Mule expression to advise thechoice exception strategy which type of messages it accepts and processes.

 CatchException Strategy:            You can define acatch exception strategy to customize the way Mule handles messages with errors.A catch exception strategy catches all exceptions thrown within its parent flowand processes them, thereby overriding Mule’s implicit default exceptionstrategy. Mule’s catch exceptionstrategy behavior is similar to a Java catch block, except that you cannotthrow a new exception or catch another exception within a catch exceptionstrategy. UseCases:             global-BKS-Choice_Exception_Strategycontains with catch-exception-strategies.  Doc:name        Catch Exception Strategy When               expression to indicate the SoapFaultException, the catch exception strategy handles when it is embedded within a Choice Exception Strategy.

            #exception.causedBy(org.mule.module.ws.consumer.SoapFaultException)” Added message processors as child elements of the catch-exception-strategy to build a flow that processes messages that throw exceptions in the parent flow. Refer to sample code below in which a set-property and expression-component.

                                                             Global-scattercatch exception strategy contains Expression to Create exception responsepayload Doc:Name       : Expression – Create exception response payload When               : Error in Web Services Flow                                      And pattern matches with KS0076 Refer to sample implementation                            Web service call and catching exceptions thrown by the service Screenshot to consume the web service of type SOAP                       Error handling by using reference exception strategy  to catch exceptions thrown by web service   Sample response after catching exception from the web service consume  WARN  2018-01-29 02:44:16,042mule-domain-santander.HTTP_Listener_mule-domain-santander.worker.01org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for{http://support.

Best services for writing your paper according to Trustpilot

Premium Partner
From $18.00 per page
4,8 / 5
4,80
Writers Experience
4,80
Delivery
4,90
Support
4,70
Price
Recommended Service
From $13.90 per page
4,6 / 5
4,70
Writers Experience
4,70
Delivery
4,60
Support
4,60
Price
From $20.00 per page
4,5 / 5
4,80
Writers Experience
4,50
Delivery
4,40
Support
4,10
Price
* All Partners were chosen among 50+ writing services by our Customer Satisfaction Team

cxf.module.mule.org/}ProxyService#{http://support.cxf.module.

mule.org/}invokehas thrown exception, unwinding noworg.apache.cxf.interceptor.Fault:Error sending HTTP request tohttp://einstein2.sov.

pre.corp/PRPRUS_ENS/ws/PROCOR_Def_Listener.            atorg.mule.module.cxf.

transport.MuleUniversalConduit$2.handleMessage(MuleUniversalConduit.java:201)~mule-module-cxf-3.9.0.jar:3.9.

0      atorg.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)~cxf-api-2.7.

19-MULE-002.jar:2.7.

19.MULE-002            atorg.apache.

cxf.endpoint.ClientImpl.doInvoke(ClientImpl.

java:572) ~cxf-api-2.7.19-MULE-002.jar:2.7.

19.MULE-002at org.apache.cxf.endpoint.

ClientImpl.invoke(ClientImpl.java:481)~cxf-api-2.7.19-MULE-002.jar:2.

7.19.MULE-002           atorg.mule.module.cxf.CxfOutboundMessageProcessor.

doSendWithClient(CxfOutboundMessageProcessor.java:293)~mule-module-cxf-3.9.0.jar:3.9.

0     atorg.mule.module.cxf.CxfOutboundMessageProcessor.process(CxfOutboundMessageProcessor.

java:131)~mule-module-cxf-3.9.0.jar:3.9.

0  Muleconfig.xml: A mule-config.xml file will be used as theroot configuration file to be loaded.

 In a simple words mule-config.xml isplace where all the common configurations can be configured. In this use casethe error handling is done in mule-config.xml see the below screenshots and formore information regarding the mule config.xml and how it works referring tourl:https://forums.mulesoft.com/questions/4473/how_to_import_other_mule_config_files_within_mule_config_xml.

html.Figure a:Figure b:                                                    Global-scattercatch exception strategy contains Expression to Create exception responsepayload which is in the configured in the mule-config.xml Doc:Name       : mule config – Create exception response payload When               : Error in Web Services Flow                                      And pattern matches with KS0076     The catch exception strategy caught the exception and the retrieves the corresponding exception message and returns the message see the screenshots. 6.      Inthis corresponding use case the even though the status code is 200 the responsebody returns is error flag with empty message.