specifying a default exception strategy

13
Specifying a default exception strategy

Upload: sivachandra-mandalapu

Post on 12-Jan-2017

15 views

Category:

Education


2 download

TRANSCRIPT

Page 1: Specifying a default exception strategy

Specifying a default exception strategy

Page 2: Specifying a default exception strategy

Abstract

• The main motto of this PPT is How to use Specifying a default exception strategy in our applications.

Page 3: Specifying a default exception strategy

Example

Page 4: Specifying a default exception strategy
Page 5: Specifying a default exception strategy
Page 6: Specifying a default exception strategy
Page 7: Specifying a default exception strategy

.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"/>• </flow>• </mule>

Page 8: Specifying a default exception strategy

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

• <mule xmlns:cluster="http://www.mulesoft.org/schema/mule/ee/cluster" 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">• <configuration defaultExceptionStrategy-ref="GlobalCatch_Exception_Strategy" doc:name="Configuration">• <http:config useTransportForUris="false"/>• </configuration>• <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 9: Specifying a default exception strategy

• Output:• If the input is valid input:• INFO 2016-12-23 10:03:37,163

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

• INFO 2016-12-23 10:03:37,233 [[ExceptionHandling].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: --Token value: ----a1b2c3d4

Page 10: Specifying a default exception strategy
Page 11: Specifying a default exception strategy

• If the input is invalid input:

• INFO 2016-12-23 10:04:02,030 [[ExceptionHandling].HTTP_Listener_Configuration.worker.02] org.mule.api.processor.LoggerMessageProcessor: -Flow started

• ERROR 2016-12-23 10:04:02,072 [[ExceptionHandling].HTTP_Listener_Configuration.worker.02] 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 12: Specifying a default exception strategy