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

<!-- START SNIPPET: spring -->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

  <!--
    || A JCA container for ActiveMQ
    -->
  <bean id="activeMQContainer" class="org.codehaus.activemq.jca.JCAContainer">

    <!-- the work manager (thread pool) for this container -->
    <property name="workManager">
      <bean id="workManager" class="org.codehaus.activemq.work.SpringWorkManager">
      </bean>
    </property>

    <!-- the JCA Resource Adapter -->
    <property name="resourceAdapter">
      <bean id="activeMQResourceAdapter" class="org.codehaus.activemq.ra.ActiveMQResourceAdapter">
        <property name="serverUrl">
          <value>vm://localhost</value>
        </property>
      </bean>
    </property>
  </bean>

  <!--
    || The TransactionManager used for XA transactions
    -->
  <bean id="transactionManager" class="org.springframework.transaction.jta.JotmFactoryBean"/>


  <!--
    || A JmsTemplate used to publish from inside a JCA message consumption thread
    -->
  <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory">

      <!-- use the same JMS Session to publish on -->
      <bean class="org.codehaus.activemq.ra.jms.ConnectionProxyFactory"/>
    </property>
  </bean>

  <!--
    || an inbound message connector using a stateful, pooled  MessageListener
    -->
  <bean id="requestResponseMEP" factory-method="addConnector" factory-bean="activeMQContainer">

    <!-- subscription details -->
    <property name="activationSpec">
      <bean class="org.codehaus.activemq.ra.ActiveMQActivationSpec">
        <property name="destination">
          <value>org.codehaus.activemq.jca.JCAContainerRequestReplyUsingXATest</value>
        </property>
        <property name="destinationType">
          <value>javax.jms.Queue</value>
        </property>
      </bean>
    </property>

    <!-- use XA transactions -->
    <property name="transactionManager">
      <ref bean="transactionManager"/>
    </property>

    <!-- This example uses a pooled bean -->
    <property name="messageListener">
      <ref bean="pooledReplyBean"/>
    </property>

  </bean>

  <!-- a pooled, non-thread safe MessageListener using ProxyFactoryBean -->
  <bean id="pooledReplyBean" class="org.codehaus.activemq.jca.TargetSourceMessageListener">
    <property name="targetSource">
      <bean id="pooledReplyBeanTargetSource" class="org.springframework.aop.target.CommonsPoolTargetSource">
        <property name="targetBeanName">
          <value>pooledReplyBeanTarget</value>
        </property>
        <property name="maxSize">
          <value>25</value>
        </property>
      </bean>
    </property>
  </bean>
  <bean id="pooledReplyBeanTarget" class="org.codehaus.activemq.jca.TestReplyBean" singleton="false">
    <property name="jmsTemplate">
      <ref bean="jmsTemplate"/>
    </property>
  </bean>

</beans>

<!-- END SNIPPET: spring -->
