Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Mule] エラーハンドリング・サンプル
<flow name="GetFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="Recieve HTTP request" allowedMethods="GET">
<http:response-builder reasonPhrase="#[flowVars['reason']]" statusCode="#[flowVars['statusCode']]"/>
</http:listener>
<db:select config-ref="Oracle_Configuration" doc:name="Perform a query in Database">
<db:dynamic-query><![CDATA[select NAME, VALUE from TEST
where NAME = #[message.inboundProperties['name']]></db:dynamic-query>
</db:select>
<json:object-to-json-transformer doc:name="Convert Object to JSON"/>
<choice-exception-strategy doc:name="Choice Exception Strategy">
<catch-exception-strategy doc:name="Catch Exception Strategy"
when="#[exception.causedBy(org.mule.module.db.internal.domain.connection.ConnectionCreationException)]">
<set-variable variableName="statusCode" value="500" doc:name="Set status code"/>
<set-variable variableName="reason" value="Internal Server Error" doc:name="Set reason phrase"/>
</catch-exception-strategy>
<catch-exception-strategy doc:name="Catch Exception Strategy"
when="#[exception.causedBy(java.sql.SQLSyntaxErrorException)]">
<set-variable variableName="statusCode" value="400" doc:name="Set status code"/>
<set-variable variableName="reason" value="Bad Request" doc:name="Set reason phrase"/>
</catch-exception-strategy>
</choice-exception-strategy>
</flow>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment