简体   繁体   中英

How to enable ActiveMQ embedded kahadb using bean configuration

I need to enable local persistence of activemq embedded broker by enabling kahadb. How can i configure kahadb in bean xml file.

<bean id="producerBroker" class="org.apache.activemq.broker.BrokerService" init-method="start" destroy-method="stop">

        <property name="brokerName" value = "producerBroker"/>
        <property name="persistent" value="true"/>
        <property name="transportConnectorURIs">
            <list>
                <value>tcp://localhost:7005</value>
            </list>
        </property>
        <property name="jmsBridgeConnectors">
            <list>
                <bean class="org.apache.activemq.network.jms.JmsQueueConnector">
                    <property name="outboundQueueConnectionFactory">
                        <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                            <property name="brokerURL" value="http://localhost:8090" />
                        </bean>
                    </property>
                    <property name="outboundQueueBridges">
                        <list>
                            <bean class="org.apache.activemq.network.jms.OutboundQueueBridge">
                                <constructor-arg value="qvsample"/>
                            </bean>
                        </list>
                    </property>
                </bean>
            </list>
        </property>
    </bean>

EDIT

ActiveMQ's default persistence db is kahoDb. this line <property name="persistent" value="true"/> made this. I need to know how to change this db to another. Moreover i need a good reference to configure spring xml file for activemq?

You can create a bean of org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter and inject it into your broker through persistenceAdapter property.

Eg

<bean id="persistenceAdapter" class="org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter">
    <property name="directory" value="D:\test"/>
</bean>

<bean id="producerBroker" class="org.apache.activemq.broker.BrokerService" init-method="start" destroy-method="stop">
    <property name="persistenceAdapter" ref="persistenceAdapter"/>
</bean>

You can use any other persistence adapter (eg leveldb) as long as it implements org.apache.activemq.store.PersistenceAdapter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM