将ActiveMQ的消息保存到MySQL中



<beans
        xmlns="http://www.springframework.org/schema/beans"
        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
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

    
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:${activemq.conf}/credentials.propertiesvalue>
        property>
    bean>

    
    <bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"
          lazy-init="false" scope="singleton"
          init-method="start" destroy-method="stop">
    bean>

    
    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}"
            schedulePeriodForDestinationPurge="10000">

        <destinationPolicy>
            <policyMap>
                <policyEntries>
                    <policyEntry queue=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC="10000"/>
                    <policyEntry topic=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC="10000">
                        
                        <pendingMessageLimitStrategy>
                            <constantPendingMessageLimitStrategy limit="1000"/>
                        pendingMessageLimitStrategy>
                    policyEntry>
                policyEntries>
            policyMap>
        destinationPolicy>


        
        <managementContext>
            <managementContext createConnector="false"/>
        managementContext>

        
        <persistenceAdapter>
            
            <jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#MySQL-DS"/>
        persistenceAdapter>


        
        <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage percentOfJvmHeap="70"/>
                memoryUsage>
                <storeUsage>
                    <storeUsage limit="100 gb"/>
                storeUsage>
                <tempUsage>
                    <tempUsage limit="50 gb"/>
                tempUsage>
            systemUsage>
        systemUsage>

        
        <transportConnectors>
            
            <transportConnector name="openwire"
                                uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="amqp"
                                uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="stomp"
                                uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="mqtt"
                                uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="ws"
                                uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
        transportConnectors>

        
        <shutdownHooks>
            <bean xmlns="http://www.springframework.org/schema/beans"
                  class="org.apache.activemq.hooks.SpringContextHook"/>
        shutdownHooks>

    broker>

    <bean id="MySQL-DS" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://127.0.0.1:3306/activemq?relaxAutoCommit=true&useUnicode=true&characterEncoding=UTF-8"/>
        <property name="username" value="netposa"/>
        <property name="password" value="netposa@123"/>
        <property name="poolPreparedStatements" value="true"/>
    bean>

    
    <import resource="jetty.xml"/>

beans>
        

你可能感兴趣的:(数据库)