Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ddossot/1314673 to your computer and use it in GitHub Desktop.
Save ddossot/1314673 to your computer and use it in GitHub Desktop.
mule-agent-based-sync-http-request-handling
<?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:http="http://www.mulesoft.org/schema/mule/http"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.2/mule-http.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.2/mule-jms.xsd">
<jms:activemq-connector name="amqConnector" specification="1.1" />
<!-- Global Transformers -->
<object-to-string-transformer name="object-to-string-transformer" />
<message-properties-transformer name="outbound-properties-remover"
scope="outbound">
<delete-message-property key=".*"/>
</message-properties-transformer>
<!-- Single Agent Service -->
<bridge name="single-agent-service"
inboundAddress="http://localhost:8080/capitalizer"
transformer-refs="object-to-string-transformer outbound-properties-remover"
outboundAddress="jms://services.capitalizer"
exchange-pattern="request-response" />
<!-- Dynamic Agent Service -->
<bridge name="dynamic-agent-service"
inboundAddress="http://localhost:8080/services"
transformer-refs="object-to-string-transformer outbound-properties-remover"
outboundAddress="jms://#[groovy:message.getInboundProperty('http.request.path').substring(1).replace('/','.')]"
exchange-pattern="request-response" />
<!-- Request Processing Agents -->
<flow name="capitalizer-agent">
<jms:inbound-endpoint queue="services.capitalizer" />
<expression-transformer>
<return-argument evaluator="groovy"
expression="org.apache.commons.lang.WordUtils.capitalize(payload)" />
</expression-transformer>
</flow>
<flow name="doublemetaphone-agent">
<jms:inbound-endpoint queue="services.doublemetaphone" />
<expression-transformer>
<return-argument evaluator="groovy"
expression="new org.apache.commons.codec.language.DoubleMetaphone().encode(payload)" />
</expression-transformer>
</flow>
</mule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment