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

<!DOCTYPE mule-configuration PUBLIC "-//MuleSource //DTD mule-configuration XML V1.0//EN"
                                "http://mule.mulesource.org/dtds/mule-configuration.dtd">

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

    <mule-environment-properties synchronous="true" remoteSync="true"/>

    <agents>
        <agent name="JmxAgent" className="org.mule.management.agents.JmxAgent"/>
        <agent name="JdmkAgent" className="org.mule.management.agents.JdmkAgent"/>
    </agents>
    <!--Testing with ActiveMq-->
    <connector name="jmsConnector" className="org.mule.transport.jms.JmsConnector">
        <properties>
            <property name="connectionFactoryJndiName" value="ConnectionFactory"/>
            <property name="jndiInitialFactory" value="org.activemq.jndi.ActiveMQInitialContextFactory"/>
            <property name="specification" value="1.1"/>
            <map name="connectionFactoryProperties">
                <property name="brokerURL" value="tcp://localhost:61616"/>
            </map>
        </properties>
    </connector>


    <!-- testing with OpenJms -->
    <!--<connector name="jmsConnector" className="org.mule.transport.jms.JmsConnector">-->
    <!--<properties>-->
    <!--<property name="connectionFactoryJndiName" value="JmsQueueConnectionFactory"/>-->
    <!--<property name="jndiInitialFactory" value="org.exolab.jms.jndi.InitialContextFactory"/>-->
    <!--<property name="jndiProviderUrl" value="tcp://localhost:3035"/>-->
    <!--</properties>-->
    <!--</connector>-->

    <endpoint-identifiers>
        <endpoint-identifier name="LoanBroker" value="vm://LoanBrokerRequests"/>
        <endpoint-identifier name="LoanBrokerQuotes" value="jms://LoanQuotes"/>
        <endpoint-identifier name="CreditAgency" value="jms://CreditAgencyService"/>
        <endpoint-identifier name="LenderService" value="jms://LenderService"/>
        <endpoint-identifier name="Bank1" value="jms://Bank1"/>
        <endpoint-identifier name="Bank2" value="jms://Bank2"/>
        <endpoint-identifier name="Bank3" value="jms://Bank3"/>
        <endpoint-identifier name="Bank4" value="jms://Bank4"/>
        <endpoint-identifier name="Bank5" value="jms://Bank5"/>
    </endpoint-identifiers>

    <model name="loan-broker">
        <mule-descriptor name="LoanBroker"
                         implementation="org.mule.example.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.example.loanbroker.Customer"
                            className="org.mule.routing.filters.PayloadTypeFilter"/>
                </router>
                <router className="org.mule.routing.outbound.StaticRecipientList">
                    <reply-to address="LoanBrokerQuotes"/>
                    <filter expression="recipients!=null" className="org.mule.routing.filters.MessagePropertyFilter"/>
                </router>
                <router className="org.mule.routing.outbound.FilteringOutboundRouter">
                    <endpoint address="LenderService"/>
                    <filter expectedType="org.mule.example.loanbroker.BankQuoteRequest"
                            className="org.mule.routing.filters.PayloadTypeFilter"/>
                </router>
            </outbound-router>

            <async-reply-router>
                <endpoint address="LoanBrokerQuotes"/>
                <router className="org.mule.example.loanbroker.routers.BankQuotesResponseAggregator"/>
            </async-reply-router>
        </mule-descriptor>

        <mule-descriptor name="CreditAgencyService"
                         implementation="org.mule.example.loanbroker.DefaultCreditAgencyService">
            <inbound-router>
                <endpoint address="CreditAgencyReceiver"/>
            </inbound-router>
        </mule-descriptor>

        <mule-descriptor name="LenderService"
                         implementation="org.mule.example.loanbroker.DefaultLenderService">
            <inbound-router>
                <endpoint address="LenderService"/>
            </inbound-router>
        </mule-descriptor>

        <mule-descriptor name="Bank1" implementation="org.mule.example.loanbroker.Bank">
            <inbound-router>
                <endpoint address="Bank1"/>
            </inbound-router>
        </mule-descriptor>

        <mule-descriptor name="Bank2" implementation="org.mule.example.loanbroker.Bank">
            <inbound-router>
                <endpoint address="Bank2"/>
            </inbound-router>
        </mule-descriptor>

        <mule-descriptor name="Bank3" implementation="org.mule.example.loanbroker.Bank">
            <inbound-router>
                <endpoint address="Bank3"/>
            </inbound-router>
        </mule-descriptor>

        <mule-descriptor name="Bank4" implementation="org.mule.example.loanbroker.Bank">
            <inbound-router>
                <endpoint address="Bank4"/>
            </inbound-router>
        </mule-descriptor>

        <mule-descriptor name="Bank5" implementation="org.mule.example.loanbroker.Bank">
            <inbound-router>
                <endpoint address="Bank5"/>
            </inbound-router>
        </mule-descriptor>
    </model>
</mule-configuration>
