defining global exception strategies

11

Click here to load reader

Upload: sivachandra-mandalapu

Post on 12-Jan-2017

21 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Defining global exception strategies

Defining global exception strategies

Page 2: Defining global exception strategies

Abstract

• The main motto of this PPT is How to use Defining global exception strategies in our applications.

Page 3: Defining global exception strategies

Example

Page 4: Defining global exception strategies
Page 5: Defining global exception strategies

.mflow• <?xml version="1.0" encoding="UTF-8"?>

• <mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"

• xmlns:spring="http://www.springframework.org/schema/beans" • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"• xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-current.xsd• http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd• http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">• <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8088" doc:name="HTTP Listener

Configuration"/>• <flow name="ExceptionHandlingFlow">• <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>• <logger message="-Flow started" level="INFO" doc:name="Logger"/>• <set-property propertyName="token" value="#[message.inboundProperties.'http.query.params'.token.toString()]"

doc:name="Property"/>• <logger message="--Token value: ----#[message.outboundProperties.token]" level="INFO" doc:name="Logger"/>• <set-payload value="{• &quot;token&quot;:&quot;#[message.outboundProperties.token]&quot;• }" doc:name="Set Payload"/>• <exception-strategy ref="GlobalCatch_Exception_Strategy" doc:name="Reference Exception Strategy"/>• </flow>• </mule>

Page 6: Defining global exception strategies

• Global flow:• <?xml version="1.0" encoding="UTF-8"?>

• <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"

• xmlns:spring="http://www.springframework.org/schema/beans" • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"• xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-current.xsd• http://www.mulesoft.org/schema/mule/core

http://www.mulesoft.org/schema/mule/core/current/mule.xsd">• <catch-exception-strategy name="GlobalCatch_Exception_Strategy">• <set-property propertyName="http.status" value="400" doc:name="Property"/>• <set-payload value="{• &quot;message&quot;:&quot;Bad Request&quot;• }" doc:name="Set Payload"/>• </catch-exception-strategy>• </mule>

Page 7: Defining global exception strategies

• Output:• If the input is valid input:• INFO 2016-12-23 09:50:35,930

[[ExceptionHandling].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: -Flow started

• INFO 2016-12-23 09:50:35,978 [[ExceptionHandling].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: --Token value: ----a1b2c3d4

Page 8: Defining global exception strategies
Page 9: Defining global exception strategies

• If the input is invalid input:

• NFO 2016-12-23 09:51:25,543 [[ExceptionHandling].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: -Flow started

• ERROR 2016-12-23 09:51:25,552 [[ExceptionHandling].HTTP_Listener_Configuration.worker.01] org.mule.exception.CatchMessagingExceptionStrategy:

• ********************************************************************************• Message : Execution of the expression

"message.inboundProperties.'http.query.params'.token.toString()" failed. (org.mule.api.expression.ExpressionRuntimeException).

• Payload : {NullPayload}• Element XML : <set-property propertyName="token"

value="#[message.inboundProperties.'http.query.params'.token.toString()]" doc:name="Property"></set-property>

• Payload Type : org.mule.transport.NullPayload• Element : /ExceptionHandlingFlow/processors/1 @ ExceptionHandling:ExceptionHandling.xml:13

(Property)• --------------------------------------------------------------------------------• Root Exception stack trace:• java.lang.NullPointerException• at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)• at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)• at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

Page 10: Defining global exception strategies