<?xml version="1.0" encoding="UTF-8"?>
<!--
    R Service Bus
    
    Copyright (c) Copyright of OpenAnalytics BVBA, 2010-2014
 
    ===========================================================================
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.
 
    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
        
    @author rsb.development@openanalytics.eu
-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean name="amqDeadLetterStrategy"
        class="org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy"
        p:queuePrefix="DLQ." />

    <bean name="amqDefaultPolicyEntry" class="org.apache.activemq.broker.region.policy.PolicyEntry"
        p:queue="r.*" p:deadLetterStrategy-ref="amqDeadLetterStrategy"
        p:prioritizedMessages="true" />

    <bean name="amqPolicyMap" class="org.apache.activemq.broker.region.policy.PolicyMap"
        p:defaultEntry-ref="amqDefaultPolicyEntry" />

    <bean name="amqBroker" class="org.apache.activemq.broker.BrokerService"
        p:brokerName="rsb-amq-broker" p:persistent="true"
        p:dataDirectoryFile="#{configuration.activeMqWorkDirectory}" p:useJmx="true"
        p:useShutdownHook="false" p:destinationPolicy-ref="amqPolicyMap"
        init-method="start" destroy-method="stop" />

    <bean name="amqRedeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy"
        p:useExponentialBackOff="true" p:maximumRedeliveries="6"
        p:queue="*" />

    <bean name="amqPrefetchPolicy" class="org.apache.activemq.ActiveMQPrefetchPolicy"
        p:all="1" />

    <bean name="amqConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory"
        p:brokerURL="vm://rsb-amq-broker" p:redeliveryPolicy-ref="amqRedeliveryPolicy"
        p:prefetchPolicy-ref="amqPrefetchPolicy" depends-on="amqBroker" />
</beans>
