Created
August 11, 2012 17:50
-
-
Save kcrimson/3325973 to your computer and use it in GitHub Desktop.
Mule 3 fork and join sample
This file contains 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:vm="http://www.mulesoft.org/schema/mule/vm" 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:mulexml="http://www.mulesoft.org/schema/mule/xml" | |
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
version="CE-3.3.0" | |
xsi:schemaLocation="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 | |
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd "> | |
<mulexml:namespace-manager> | |
<mulexml:namespace uri="http://musicbrainz.org/ns/mmd-2.0#" | |
prefix="mb" /> | |
</mulexml:namespace-manager> | |
<flow name="workIn"> | |
<http:inbound-endpoint host="127.0.0.1" | |
port="8080" path="work" exchange-pattern="request-response"> | |
</http:inbound-endpoint> | |
<expression-transformer expression="#[header:INBOUND:name]" doc:name="Extract query parameter"/> | |
<http:outbound-endpoint host="musicbrainz.org" | |
port="80" path="ws/2/artist?query=#[payload:]" method="GET" doc:name="Search for artists' MBID " /> | |
<splitter evaluator="xpath" expression="/mb:metadata/mb:artist-list/mb:artist" | |
doc:name="Split by found artists" /> | |
<mulexml:xpath-extractor-transformer | |
expression="/mb:artist/@id" resultType="STRING" doc:name="Extract MBID"/> | |
<collection-aggregator doc:name="Aggregate collection of MBIDs"/> | |
<request-reply storePrefix="workStore" doc:name="Put collection of MBIDs on queue for processing"> | |
<vm:outbound-endpoint path="dispatchIn"> | |
<message-properties-transformer | |
scope="outbound"> | |
<delete-message-property key="MULE_REPLYTO" /> | |
</message-properties-transformer> | |
</vm:outbound-endpoint> | |
<vm:inbound-endpoint path="dispatchOut" /> | |
</request-reply> | |
<custom-transformer class="com.examples.mule.XMLAggregator" doc:name="Merge response in resulting XML" /> | |
<mulexml:dom-to-xml-transformer/> | |
</flow> | |
<flow name="workDispatcher"> | |
<vm:inbound-endpoint path="dispatchIn" /> | |
<collection-splitter enableCorrelation="ALWAYS" /> | |
<flow-ref name="workWorker" /> | |
</flow> | |
<flow name="workWorker"> | |
<message-properties-transformer scope="invocation" doc:name="Remember correlation"> | |
<add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_ID]" key="cid" /> | |
<add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_GROUP_SIZE]" key="cgs" /> | |
</message-properties-transformer> | |
<all> | |
<processor-chain> | |
<http:outbound-endpoint host="ws.audioscrobbler.com" | |
port="80" | |
path="2.0/?method=artist.getinfo&mbid=#[payload:]&api_key=b25b959554ed76058ac220b7b2e0a026" | |
method="GET" doc:name="Query LastFm fro artist's bio" /> | |
<mulexml:xpath-extractor-transformer expression="/lfm/artist/bio" resultType="NODE"/> | |
</processor-chain> | |
<processor-chain> | |
<http:outbound-endpoint host="ws.audioscrobbler.com" | |
port="80" | |
path="2.0/?method=artist.getevents&mbid=#[payload:]&api_key=b25b959554ed76058ac220b7b2e0a026" | |
method="GET" doc:name="Query LastFm for artist's events" /> | |
<mulexml:xpath-extractor-transformer expression="/lfm/events" resultType="NODE"/> | |
</processor-chain> | |
<processor-chain> | |
<http:outbound-endpoint host="musicbrainz.org" | |
port="80" path="ws/2/artist/#[payload:]?inc=releases+media" method="GET" | |
doc:name="Query MusicBrainz for artist's releases" /> | |
<mulexml:xpath-extractor-transformer expression="/metadata/artist/release-list" resultType="NODE"/> | |
</processor-chain> | |
</all> | |
<message-properties-transformer scope="outbound"> | |
<add-message-property value="#[header:INVOCATION:cid]" key="MULE_CORRELATION_ID" /> | |
<add-message-property value="#[header:INVOCATION:cgs]" key="MULE_CORRELATION_GROUP_SIZE" /> | |
</message-properties-transformer> | |
<vm:outbound-endpoint path="aggregatorIn" /> | |
</flow> | |
<flow name="workAggregator"> | |
<vm:inbound-endpoint path="aggregatorIn" /> | |
<collection-aggregator /> | |
<vm:outbound-endpoint path="dispatchOut" /> | |
</flow> | |
</mule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment