<?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.
This implementation differs in that this configuration uses an asynchronous
model where each component communicates messaging accordin to it's configuration
in this file.
There is a synchronous version of this in the loan-broker-sync-config.xml where calls to
the different components are made from the loan broker component (a la hub and spoke).
-->

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

    <mule-environment-properties serverUrl="">
        <threading-profile maxBufferSize="0" maxThreadsActive="5" maxThreadsIdle="5" poolExhaustedAction="RUN" threadTTL="3000000"/>
        <pooling-profile maxActive="5" maxIdle="5" exhaustedAction="GROW" maxWait="1000"/>
        <queue-profile maxOutstandingMessages="200"/>
    </mule-environment-properties>

    <agents>
        <agent name="JmxAgent" className="org.mule.management.agents.JmxAgent"/>
        <agent name="JdmkAgent" className="org.mule.management.agents.JdmkAgent"/>
        <!--       <agent name="Mx4jAgent" className="org.mule.management.agents.Mx4jAgent" />-->
        <!--       <agent name="Log4jAgent" className="org.mule.management.agents.Log4jAgent" />-->
    </agents>

    <!--
    Setting global endpoints can help simplify configuration by defining an actual
    url endpointUri in one place. The endpointUri name can be used in place of the url.
    -->
    <endpoint-identifiers>
        <endpoint-identifier name="LoanBrokerRequests" value="vm://LoanBrokerRequests"/>
        <endpoint-identifier name="LoanBrokerQuotes" value="vm://LoanBrokerQuotes"/>
        <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"/>
        <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>

    <!--    <endpoint-identifiers>-->
    <!--        <endpoint-identifier name="LoanBrokerRequests" value="vm://LoanBrokerRequests"/>-->
    <!--        <endpoint-identifier name="LoanBrokerQuotes" value="vm://LoanBrokerQuotes"/>-->
    <!--        <endpoint-identifier name="CreditAgency" value="glue:http://localhost:18080/mule/CreditAgencyService?method=getCreditProfile"/>-->
    <!--        <endpoint-identifier name="CreditAgencyReceiver" value="glue:http://localhost:18080/mule"/>-->
    <!--        <endpoint-identifier name="LenderService" value="vm://localhost/LenderService"/>-->
    <!--        <endpoint-identifier name="Bank1" value="glue:http://localhost:10080/mule"/>-->
    <!--        <endpoint-identifier name="Bank2" value="glue:http://localhost:20080/mule"/>-->
    <!--        <endpoint-identifier name="Bank3" value="glue:http://localhost:30080/mule"/>-->
    <!--        <endpoint-identifier name="Bank4" value="glue:http://localhost:40080/mule"/>-->
    <!--        <endpoint-identifier name="Bank5" value="glue:http://localhost:50080/mule"/>-->
    <!--    </endpoint-identifiers>-->

    <!--
       The Mule model initialises and manages your UMO components
   -->
    <model name="loan-broker">
        <!-- by declaring the Axis service component we can overload its default
        configuration to add more threads or pooled resources -->
        <mule-descriptor name="_axisServiceComponent"
            implementation="org.mule.providers.soap.axis.AxisServiceComponent">
            <threading-profile maxBufferSize="100" threadTTL="600000" maxThreadsActive="30" maxThreadsIdle="20"/>
            <pooling-profile exhaustedAction="WAIT" maxActive="20" maxIdle="20" maxWait="20000"/>
        </mule-descriptor>
        <!--
        The loan broker is used to receive loan requests
        -->
        <mule-descriptor name="LoanBroker"
            outboundEndpoint="CreditAgency"
            implementation="org.mule.samples.loanbroker.AsyncLoanBroker">

            <!--
            This router uses the BankQuotesAggregator for events of type BankQuote, for all other
            types the catch all strategy is invoked, which simply passes the event to the component
            -->
            <inbound-router>
                <catch-all-strategy className="org.mule.routing.ComponentCatchAllStrategy"/>
                <endpoint address="LoanBrokerRequests"/>
                <endpoint address="LoanBrokerQuotes"/>
                <router className="org.mule.samples.loanbroker.routers.BankQuotesAggregator">
                    <filter expectedType="org.mule.samples.loanbroker.LoanQuote" className="org.mule.routing.filters.PayloadTypeFilter"/>
                </router>
            </inbound-router>
            <!--            <queue-profile maxOutstandingMessages="150" blockWait="3000" />-->
            <!--            <pooling-profile maxActive="20" maxIdle="10" exhaustedAction="GROW" maxWait="10000" />-->
            <!--            <threading-profile maxBufferSize="100" maxThreadsActive="20" maxThreadsIdle="5" poolExhaustedAction="RUN" threadTTL="60000" />-->
        </mule-descriptor>

        <!--
        The credit agency service will get the credit profile for a customer
        -->
        <mule-descriptor name="CreditAgencyService"
            inboundEndpoint="CreditAgencyReceiver"
            outboundEndpoint="LenderService"
            implementation="org.mule.samples.loanbroker.DefaultCreditAgencyService">
        </mule-descriptor>

        <!--
        The Lender service is used to determine which banks to contact for a quote
        -->
        <mule-descriptor name="LenderService"
            inboundEndpoint="LenderService"
            implementation="org.mule.samples.loanbroker.DefaultLenderService">
            <!--
            this router will send an outbound event to none or more recipients which
            are set as a property on the event itelf.  A replyTo property is also set
            which tells the recipients of the event where to send the resulting event
            -->
            <outbound-router>
                <catch-all-strategy className="org.mule.routing.LoggingCatchAllStrategy"/>
                <router className="org.mule.routing.outbound.StaticRecipientList">
                    <reply-to address="LoanBrokerQuotes"/>
                </router>
            </outbound-router>
        </mule-descriptor>

        <!--
        These are mock bank services that represent remote bank loan services
        One or more of these are selected by the LenderService and a request
        is routed to them.   The lenderService outbound router also defines a
        replyTo property which will be used by Mule to route the responses back
        to the LoanBrokerQuotes destination
        -->
        <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>
    </model>
</mule-configuration>