<?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.activemq.jca.JCAContainer">

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

    <!-- the JCA Resource Adapter -->
    <property name="resourceAdapter">
      <bean id="activeMQResourceAdapter" class="org.activemq.ra.ActiveMQResourceAdapter">
         <property name="serverUrl">
          <value>tcp://localhost:61616</value>
        </property>
        <property name="useEmbeddedBroker">
          <value>true</value>
        </property>
        <property name="brokerXmlConfig">
          <value>org/activemq/jca/broker.xml</value>
        </property>
      </bean>
    </property>

  </bean>


  <!--
    || 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.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.activemq.ra.ActiveMQActivationSpec">
        <property name="destination">
          <value>org.activemq.jca.JCAContainerRequestReplyTest</value>
        </property>
        <property name="destinationType">
          <value>javax.jms.Queue</value>
        </property>
      </bean>
    </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.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.activemq.jca.TestReplyBean" singleton="false">
    <property name="jmsTemplate">
      <ref bean="jmsTemplate"/>
    </property>
  </bean>

</beans>

<!-- END SNIPPET: spring -->
