Created
July 20, 2012 22:27
-
-
Save ddossot/3153668 to your computer and use it in GitHub Desktop.
Mule - Unbounce Webhooks Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:json="http://www.mulesoft.org/schema/mule/json" | |
xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" | |
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" | |
xmlns:spring="http://www.springframework.org/schema/beans" | |
xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
version="CE-3.3.0" | |
xsi:schemaLocation=" | |
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd | |
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd | |
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd | |
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 "> | |
<spring:beans> | |
<spring:bean id="objectStore" | |
class="org.mule.util.store.SimpleMemoryObjectStore" /> | |
<spring:bean id="jacksonObjectMapper" | |
class="org.codehaus.jackson.map.ObjectMapper" /> | |
<spring:bean id="jacksonSerializationConfig" | |
class="org.codehaus.jackson.map.SerializationConfig" | |
factory-method="getSerializationConfig" factory-bean="jacksonObjectMapper" /> | |
<spring:bean | |
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> | |
<spring:property name="targetObject" | |
ref="jacksonSerializationConfig" /> | |
<spring:property name="targetMethod" value="set" /> | |
<spring:property name="arguments"> | |
<spring:list> | |
<spring:value>WRITE_NULL_MAP_VALUES</spring:value> | |
<spring:value>false</spring:value> | |
</spring:list> | |
</spring:property> | |
</spring:bean> | |
</spring:beans> | |
<vm:connector name="VM" doc:name="VM"> | |
<vm:queue-profile maxOutstandingMessages="10000" /> | |
</vm:connector> | |
<flow name="unbounceWebhookHandler" doc:name="unbounceWebhookHandler"> | |
<http:inbound-endpoint exchange-pattern="request-response" | |
host="localhost" port="${http.port}" path="webhooks/unbounce" | |
doc:name="Unbounce Webhook Endpoint" /> | |
<http:body-to-parameter-map-transformer | |
doc:name="To Parameter Map" /> | |
<response> | |
<expression-transformer expression="'OK'" | |
doc:name="OK" /> | |
</response> | |
<expression-transformer expression="message.payload['data.json']" | |
doc:name="Extract JSON Data" /> | |
<json:json-to-object-transformer | |
returnClass="java.util.HashMap" doc:name="JSON to Map" /> | |
<expression-transformer | |
expression="['email':message.payload.email[0],'ip_address':message.payload.ip_address[0]]" | |
doc:name="Single Values" /> | |
<vm:outbound-endpoint exchange-pattern="one-way" | |
path="signups.in" doc:name="Signups Queue" /> | |
</flow> | |
<flow name="signupEnricher" doc:name="signupEnricher"> | |
<vm:inbound-endpoint exchange-pattern="one-way" | |
path="signups.in" doc:name="Signups Queue" /> | |
<enricher doc:name="Enrich with Profile data"> | |
<core:flow-ref name="idlightSafeInvoker" | |
doc:name="Invoke | |
IDlight" /> | |
<enrich source="message.payload.?name.full" target="message.payload.name" /> | |
<enrich source="message.payload.?organizations.?get(0).name" | |
target="message.payload.company" /> | |
<enrich source="message.payload.?abouts.?get(0)" | |
target="message.payload.about" /> | |
</enricher> | |
<json:object-to-json-transformer | |
mapper-ref="jacksonObjectMapper" doc:name="Object to JSON" /> | |
<until-successful objectStore-ref="objectStore" | |
maxRetries="5" secondsBetweenRetries="60" | |
failureExpression="message.inboundProperties['http.status'] != 200" | |
doc:name="Until Successful"> | |
<http:outbound-endpoint | |
exchange-pattern="request-response" host="api.prancingdonkey.com" | |
path="signups/digest" port="80" doc:name="To Prancing Donkey" | |
method="POST" contentType="application/json" /> | |
</until-successful> | |
</flow> | |
<flow name="idlightSafeInvoker" doc:name="idlightSafeInvoker" | |
processingStrategy="synchronous"> | |
<set-property propertyName="Accept" value="application/json" | |
doc:name="Accept JSON" /> | |
<http:outbound-endpoint | |
address="http://api.idlight.net/lookup?q=#[message.payload.email]" | |
exchange-pattern="request-response" method="GET" | |
responseTimeout="30000" doc:name="Call IDlight" /> | |
<json:json-to-object-transformer | |
ignoreBadInput="false" returnClass="java.util.HashMap" | |
doc:name="JSON to Map" /> | |
<catch-exception-strategy doc:name="Catch Exception Strategy"> | |
<expression-component doc:name="Empty Profile"> | |
payload = [:] | |
</expression-component> | |
</catch-exception-strategy> | |
</flow> | |
</mule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment