<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">


    <bean id="connectionFactory" class="bitronix.tm.resource.jms.PoolingConnectionFactory" init-method="init"
          destroy-method="close" depends-on="activeMqBrokerService">
        <property name="className" value="org.apache.activemq.spring.ActiveMQXAConnectionFactory"/>
        <property name="uniqueName" value="activemq"/>
        <property name="maxPoolSize" value="20"/>
        <property name="driverProperties">
            <props>
                <prop key="brokerURL">
                    <![CDATA[vm://broker?create=false&waitForStart=5000&jms.redeliveryPolicy.maximumRedeliveries=2]]>
                </prop>
            </props>
        </property>
    </bean>

    <bean id="destinationResolver"
          class="org.springframework.jms.support.destination.BeanFactoryDestinationResolver"/>

    <!-- Create the actual broker -->
    <bean id="activeMqBrokerService" class="org.apache.activemq.broker.BrokerService"
          init-method="start"
          destroy-method="stop">
        <property name="brokerName" value="broker"/>
        <property name="dataDirectoryFile" value="target/activemq"/>
        <property name="useJmx" value="false"/>
        <property name="transportConnectorURIs">
            <list>
                <value>vm://broker</value>
            </list>
        </property>
        <property name="destinationPolicy" ref="activeMqDestinationPolicy"/>
        <property name="persistent" value="false"/>
    </bean>

    <bean id="activeMqDestinationPolicy" class="org.apache.activemq.broker.region.policy.PolicyMap">
        <property name="defaultEntry">
            <bean class="org.apache.activemq.broker.region.policy.PolicyEntry">
                <property name="queue" value=">"/>
                <property name="deadLetterStrategy">
                    <bean class="org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy">
                        <property name="queuePrefix" value="DLQ."/>
                        <property name="topicPrefix" value="DLQ."/>
                        <property name="useQueueForQueueMessages" value="true"/>
                        <property name="useQueueForTopicMessages" value="true"/>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>

</beans>

