<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:spring="http://www.springframework.org/schema/beans"
        xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2"
        xsi:schemaLocation="
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
                http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd">

     <description>
     This loan broker example is modeled on the Enterprise integration Patterns book sample.
     This implementation differs in that this configuration uses a synchronous model where
     each component is invoked from the LoanBroker component.
     </description>

     <!-- Synchronous VM connector (messages are processed in the same execution thread) -->
     <vm:connector name="syncVm"/>

    <!--
       The Mule model initialises and manages your Mule components
     -->
    <model name="loan-broker">

             <!--
             The loan broker is used to receive loan requests
             -->
             <service name="TheLoanBroker">
                 <inbound>
                     <inbound-endpoint ref="CustomerRequests"/>
                 </inbound>

                 <component class="org.mule.example.loanbroker.esn.SynchronousLoanBroker">
                     <binding interface="org.mule.example.loanbroker.credit.CreditAgencyService">
                         <outbound-endpoint ref="CreditAgency"/>
                     </binding>
                 </component>

                 <outbound>
                     <pass-through-router>
                         <outbound-endpoint ref="LenderService"/>
                     </pass-through-router>
                 </outbound>

                 <async-reply timeout="1000000">
                     <inbound-endpoint ref="LoanBrokerQuotes"/>
                     <custom-async-reply-router class="org.mule.example.loanbroker.routers.BankQuotesResponseAggregator"/>
                 </async-reply>
             </service>

             <!--
             The credit agency service will get the credit profile for a customer
             -->
             <service name="TheCreditAgencyService">
                 <inbound>
                     <inbound-endpoint ref="CreditAgencyIn"/>
                 </inbound>
                 <component class="org.mule.example.loanbroker.credit.DefaultCreditAgency"/>
             </service>

             <!--
             The Lender service is used to determine which banks to contact for a quote
             -->
             <service name="TheLenderService">
                 <inbound>
                     <inbound-endpoint ref="LenderService"/>
                 </inbound>
                 <component class="org.mule.example.loanbroker.lender.DefaultLender"/>
                 <outbound>
                     <pass-through-router>
                         <outbound-endpoint ref="BankGateway" transformer-refs="SetLendersAsRecipients"/>
                     </pass-through-router>
                 </outbound>
             </service>

             <service name="TheBankGateway">
                 <inbound>
                     <inbound-endpoint ref="BankGateway"/>
                     <forwarding-router/>
                 </inbound>
                 <outbound>
                     <static-recipient-list-router>
                         <reply-to address="LoanBrokerQuotes"/>
                         <message-property-filter pattern="recipients!=null"/>
                     </static-recipient-list-router>
                     <logging-catch-all-strategy/>                     
                 </outbound>
             </service>

             <!--
             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
             -->
             <service name="TheBank1">
                 <inbound>
                     <inbound-endpoint ref="Bank1In"/>
                 </inbound>
                 <component class="org.mule.example.loanbroker.bank.Bank"/>
             </service>

             <service name="TheBank2">
                 <inbound>
                     <inbound-endpoint ref="Bank2In"/>
                 </inbound>
                 <component class="org.mule.example.loanbroker.bank.Bank"/>
             </service>

             <service name="TheBank3">
                 <inbound>
                     <inbound-endpoint ref="Bank3In"/>
                 </inbound>
                 <component class="org.mule.example.loanbroker.bank.Bank"/>
             </service>

             <service name="TheBank4">
                 <inbound>
                     <inbound-endpoint ref="Bank4In"/>
                 </inbound>
                 <component class="org.mule.example.loanbroker.bank.Bank"/>
             </service>

             <service name="TheBank5">
                 <inbound>
                     <inbound-endpoint ref="Bank5In"/>
                 </inbound>
                 <component class="org.mule.example.loanbroker.bank.Bank"/>
             </service>

         </model>
</mule>
