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

    <jbossts:transaction-manager/>

    <vm:connector name="vm" queueEvents="true"/>

    <jms:activemq-xa-connector name="jmsConnectorTestDriver" specification="1.1"/>

    <jms:activemq-xa-connector name="jmsConnectorC1" specification="1.1" durable="true" clientId="C1"
            numberOfConcurrentTransactedReceivers="1"/>

    <jms:activemq-xa-connector name="jmsConnectorC2" specification="1.1" durable="true" clientId="C2"
        numberOfConcurrentTransactedReceivers="1"/>

    <vm:endpoint name="in" path="in" connector-ref="vm"/>
    <vm:endpoint name="out" path="out" connector-ref="vm"/>

    <model name="TEST">

        <service name="InputPart">
            <inbound>
                <inbound-endpoint ref="in"/>
            </inbound>
            <component>
                <singleton-object class="org.mule.tck.functional.FunctionalTestComponent">
                    <property key="returnMessage" value="OUTPUT MESSAGE"/>
                </singleton-object>
            </component>
            <outbound>
                <outbound-pass-through-router>
                    <jms:outbound-endpoint topic="durable.broadcast" connector-ref="jmsConnectorTestDriver"/>
                    <!--
                        There's no inbound TX, so make sure XA is happy by starting it via router
                        on the outbound. Such problems are now nicely detected and reported via an error.
                    -->
                    <jms:xa-transaction action="BEGIN_OR_JOIN"/>
                </outbound-pass-through-router>
            </outbound>
        </service>

        <service name="Part1">
            <inbound>
                <jms:inbound-endpoint topic="durable.broadcast" connector-ref="jmsConnectorC1">
                    <jms:xa-transaction action="BEGIN_OR_JOIN"/>
                </jms:inbound-endpoint>
            </inbound>
            <component>
                <singleton-object class="org.mule.tck.functional.FunctionalTestComponent">
                    <property key="returnMessage" value="OUTPUT MESSAGE-1"/>
                </singleton-object>
            </component>
            <outbound>
                <outbound-pass-through-router>
                    <outbound-endpoint ref="out"/>
                </outbound-pass-through-router>
            </outbound>
        </service>

        <service name="Part3">
            <inbound>
                <jms:inbound-endpoint topic="durable.broadcast" connector-ref="jmsConnectorC2">
                    <jms:xa-transaction action="BEGIN_OR_JOIN"/>
                </jms:inbound-endpoint>
            </inbound>
            <component>
                <singleton-object class="org.mule.tck.functional.FunctionalTestComponent">
                    <property key="returnMessage" value="OUTPUT MESSAGE-2"/>
                </singleton-object>
            </component>
            <outbound>
                <outbound-pass-through-router>
                    <outbound-endpoint ref="out"/>
                </outbound-pass-through-router>
            </outbound>
        </service>

    </model>
</mule>
