<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC
    "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

  <bean id="jmsFactory" class="org.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL">
      <value>tcp://localhost:61616</value>
    </property>
  </bean>

  <!-- JCA container for ActiveMQ -->
  <bean id="activeMQContainer" class="org.activemq.jca.JCAContainer" depends-on="jmsFactory" singleton="true">

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

  <!-- inbound message connector -->
  <bean id="messageConnector" factory-method="addConnector" factory-bean="activeMQContainer">

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

    <!-- the bean used to process the message -->
    <property name="messageListener">
      <ref bean="consumerBean"/>
    </property>
  </bean>

  <bean id="consumerBean" class="org.activemq.jca.TestBean" singleton="true"/>

</beans>
