<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mule-configuration PUBLIC "-//SymphonySoft //DTD mule-configuration XML V1.0//EN"
                                "http://www.symphonysoft.com/dtds/mule/mule-configuration.dtd">

<!--
This loan broker example is modeled on the Enterprise integration Patterns book
sample.
The example invokes the Credit Agency and Lender service synchronously form the LoanBroker
(i.e. Hub n' Spoke pattern) Then it dispatches loan requests Asynchronously to all the banks
(as these requests can be made in parallel).  There is a Response router on the LoanBroker component
that receives the results form each of the banks and selects the lowest quote.
-->

<mule-configuration id="Loan_broker_Sync" version="1.0">

    <endpoint-identifiers>
        <endpoint-identifier name="LoanBrokerRequests" value="vm://LoanBrokerRequests"/>
        <endpoint-identifier name="LoanBrokerQuotes" value="vm://LoanQuotes"/>
        <endpoint-identifier name="CreditAgency" value="axis:http://localhost:18080/mule/CreditAgencyService?method=getCreditProfile"/>
        <endpoint-identifier name="CreditAgencyReceiver" value="axis:http://localhost:18080/mule"/>
        <endpoint-identifier name="LenderService" value="vm://localhost/LenderService?method=setLenderList"/>
        <!-- The method parameter for the bank endpoints is added programmitcally when the bank objects are
        created -->
        <endpoint-identifier name="Bank1" value="axis:http://localhost:10080/mule"/>
        <endpoint-identifier name="Bank2" value="axis:http://localhost:20080/mule"/>
        <endpoint-identifier name="Bank3" value="axis:http://localhost:30080/mule"/>
        <endpoint-identifier name="Bank4" value="axis:http://localhost:40080/mule"/>
        <endpoint-identifier name="Bank5" value="axis:http://localhost:50080/mule"/>
    </endpoint-identifiers>

    <mule-descriptor name="LoanBroker"
        implementation="org.mule.samples.loanbroker.SyncLoanBroker">
        <inbound-router>
            <endpoint address="LoanBrokerRequests"/>
        </inbound-router>

        <outbound-router>
            <router className="org.mule.routing.outbound.FilteringOutboundRouter">
                <endpoint address="CreditAgency"/>
                <filter expectedType="org.mule.samples.loanbroker.Customer" className="org.mule.routing.filters.PayloadTypeFilter"/>
            </router>
            <router className="org.mule.routing.outbound.FilteringOutboundRouter">
                <endpoint address="LenderService"/>
                <filter expectedType="org.mule.samples.loanbroker.BankQuoteRequest" className="org.mule.routing.filters.PayloadTypeFilter"/>
            </router>
        </outbound-router>
        <response-router timeout="100000">
            <endpoint address="LoanBrokerQuotes"/>
            <router className="org.mule.samples.loanbroker.routers.BankQuotesResponseAggregator"/>
        </response-router>
    </mule-descriptor>

    <mule-descriptor name="CreditAgencyService"
        inboundEndpoint="CreditAgencyReceiver"
        implementation="org.mule.samples.loanbroker.DefaultCreditAgencyService">
    </mule-descriptor>

    <mule-descriptor name="LenderService"
        inboundEndpoint="LenderService"
        implementation="org.mule.samples.loanbroker.DefaultLenderService">
        <outbound-router>
            <router className="org.mule.routing.outbound.StaticRecipientList">
                <reply-to address="LoanBrokerQuotes"/>
                <filter expression="recipients!=null" className="org.mule.routing.filters.MessagePropertyFilter"/>
            </router>
        </outbound-router>
    </mule-descriptor>

    <mule-descriptor name="Bank1"
        inboundEndpoint="Bank1"
        implementation="org.mule.samples.loanbroker.Bank">
    </mule-descriptor>

    <mule-descriptor name="Bank2"
        inboundEndpoint="Bank2"
        implementation="org.mule.samples.loanbroker.Bank">
    </mule-descriptor>

    <mule-descriptor name="Bank3"
        inboundEndpoint="Bank3"
        implementation="org.mule.samples.loanbroker.Bank">
    </mule-descriptor>

    <mule-descriptor name="Bank4"
        inboundEndpoint="Bank4"
        implementation="org.mule.samples.loanbroker.Bank">
    </mule-descriptor>

    <mule-descriptor name="Bank5"
        inboundEndpoint="Bank5"
        implementation="org.mule.samples.loanbroker.Bank">
    </mule-descriptor>
</mule-configuration>