Skip to content

Instantly share code, notes, and snippets.

@maxcao
Created February 1, 2012 19:13
Show Gist options
  • Save maxcao/1718714 to your computer and use it in GitHub Desktop.
Save maxcao/1718714 to your computer and use it in GitHub Desktop.
Mule Config XML
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.1/mule-http.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.1/mule-vm.xsd">
<description>
This configuration uses an HTTP endpoint to receive requests.
</description>
<!--
To invoke the Hello service over HTTP, hit the following URL in your browser:
http://localhost:8888?name=Ross
To invoke the Hello service via a Servlet, submit a web form such as:
<form method="POST" action="/mule-examples/rest?endpoint=greeter">
<input type="text" name="payload"/>
<input type="submit" value="POST" />
</form>
-->
<custom-transformer name="StringToNameString" class="org.mule.example.hello.StringToNameString"/>
<custom-transformer name="NameStringToChatString" class="org.mule.example.hello.NameStringToChatString"/>
<custom-transformer name="ChatStringToString" class="org.mule.example.hello.ChatStringToString"/>
<custom-transformer name="HttpRequestToNameString" class="org.mule.example.hello.HttpRequestToNameString"/>
<custom-transformer name="ExceptionToString" class="org.mule.example.hello.ExceptionToString"/>
<custom-transformer name="HttpRequestToParameter" class="org.mule.transport.servlet.transformers.HttpRequestToParameter"/>
<custom-transformer name="ObjectToString" class="org.mule.transformer.simple.ObjectToString"/>
<flow name="Hello World">
<composite-source>
<!-- Incoming HTTP requests -->
<inbound-endpoint address="http://localhost:${http.port}" transformer-refs="HttpRequestToNameString" exchange-pattern="request-response"/>
<!-- Incoming Servlet requests -->
<inbound-endpoint address="servlet://name" transformer-refs="HttpRequestToNameString" exchange-pattern="request-response"/>
<!-- Incoming VM requests -->
<vm:inbound-endpoint path="greeter" transformer-refs="StringToNameString" exchange-pattern="request-response"/>
</composite-source>
<message-filter>
<not-filter>
<wildcard-filter pattern="/favicon.ico"/>
</not-filter>
</message-filter>
<component class="org.mule.example.hello.Greeter"/>
<choice>
<when expression="payload instanceof org.mule.example.hello.NameString" evaluator="groovy">
<vm:outbound-endpoint path="chitchatter" exchange-pattern="request-response"/>
</when>
<when expression="payload instanceof java.lang.Exception" evaluator="groovy">
<vm:outbound-endpoint path="userErrorHandler" exchange-pattern="request-response"/>
</when>
</choice>
<!-- Route unexpected errors to separate error handler -->
<default-exception-strategy>
<vm:outbound-endpoint path="systemErrorHandler" exchange-pattern="one-way"/>
</default-exception-strategy>
</flow>
<model>
<service name="UserErrorHandler">
<inbound>
<vm:inbound-endpoint path="userErrorHandler" responseTransformer-refs="ExceptionToString" exchange-pattern="request-response"/>
</inbound>
</service>
</model>
<flow name="ChitChat">
<vm:inbound-endpoint path="chitchatter" transformer-refs="NameStringToChatString"
responseTransformer-refs="ChatStringToString" exchange-pattern="request-response"/>
<component class="org.mule.example.hello.ChitChatter"/>
</flow>
<!-- Handle any unexpected errors. Errors could also be routed elsewhere,
e.g. into an error file, send via email to a list, stored in a database, etc. -->
<flow name="SystemErrorHandler">
<vm:inbound-endpoint path="systemErrorHandler" exchange-pattern="request-response"/>
<outbound-endpoint address="stdio://ERR" exchange-pattern="one-way"/>
</flow>
</mule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment