Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <asynchronous-processing-strategy name="500Threads" maxThreads="500"/>
- <flow name="work2In">
- <description>
- <![CDATA[
- Work-2 Demo.
- This demonstrates an synchronous HTTP request -> asynchronous splitter, processing, and aggregation, back to the original
- synchronous HTTP reply.
- The message payload is transformed into a collection (list) of 500 elements, which is sent to the work2request asynchronous VM. The
- synchronous HTTP thread waits for a single message to arrive over the work2reply asynchronous VM endpoint.
- Upon the single message arriving on the work2request VM inbound endpoint, the message is split into 500 individual messages via the
- collection splitter, and each message is sent to the asynchronous flow work2worker. The flow work2worker will execute asynchronously,
- based on its processing model. Each message has its payload replaced with the respective message correlation id, which is transformed
- to demonstrate a content change. The message is then sent to work2workreply asynchronous VM endpoint.
- The work2workreply VM endpoint aggregates each message back into the original collection (unsorted), which is send back to the HTTP
- synchronous thread via the work2reply VM endpoint.
- ]]>
- </description>
- <http:inbound-endpoint name="httpWork2In"
- host="127.0.0.1" port="8080"
- path="work-2" exchange-pattern="request-response">
- </http:inbound-endpoint>
- <expression-transformer evaluator="groovy" expression="1..500"/>
- <request-reply storePrefix="work2Store">
- <vm:outbound-endpoint path="work2request">
- <message-properties-transformer scope="outbound">
- <delete-message-property key="MULE_REPLYTO"/>
- </message-properties-transformer>
- </vm:outbound-endpoint>
- <vm:inbound-endpoint path="work2reply" exchange-pattern="one-way"/>
- </request-reply>
- <logger message="Final payload: #[groovy:payload.size()] elements" level="ERROR"/>
- <logger message="Final payload: #[payload]" level="ERROR"/>
- <json:object-to-json-transformer/>
- <logger message="Done." level="ERROR"/>
- </flow>
- <flow name="work2dispatcher">
- <vm:inbound-endpoint path="work2request" exchange-pattern="one-way"/>
- <collection-splitter/>
- <flow-ref name="work2worker"/>
- </flow>
- <flow name="work2aggregator" processingStrategy="500Threads">
- <vm:inbound-endpoint path="work2workreply" exchange-pattern="one-way"/>
- <collection-aggregator/>
- <combine-collections-transformer/>
- <logger message="Aggregated payload: #[groovy:payload.size()] elements" level="ERROR"/>
- <logger message="Aggregated payload: #[payload]" level="ERROR"/>
- <vm:outbound-endpoint path="work2reply" exchange-pattern="one-way"/>
- </flow>
- <flow name="work2worker" processingStrategy="500Threads">
- <expression-transformer evaluator="message" expression="correlationSequence"/>
- <logger message="ID: #[payload]" level="ERROR"/>
- <transformer ref="multiplier"/>
- <vm:outbound-endpoint path="work2workreply" exchange-pattern="one-way"/>
- </flow>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement