2011-10-07

【系統】ActiveMQ : Final Config File - ActiveMQ.xml

這裡來完整記錄一下我的 Config 檔吧。
/home/activemq/conf/activemq.xml

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

    <!-- Allows us to use system properties as variables in this configuration file -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:${activemq.base}/conf/credentials.properties</value>
        </property>      
    </bean>

    <!-- 
        The <broker> element is used to configure the ActiveMQ broker. 
    -->
    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="brokerA" brokerId="A" dataDirectory="${activemq.base}/data" destroyApplicationContextOnStop="true" persistent="true">
    
        <destinationPolicy>
            <policyMap>
              <policyEntries>
                <policyEntry topic=">" producerFlowControl="false" memoryLimit="128mb" topicPrefetch="1000">
                  <pendingSubscriberPolicy>
                    <vmCursor />
                  </pendingSubscriberPolicy>
                </policyEntry>
                <policyEntry queue=">" producerFlowControl="false" memoryLimit="128mb" queuePrefetch="1">
                </policyEntry>
              </policyEntries>
            </policyMap>
        </destinationPolicy>

        
        <managementContext>
            <managementContext createConnector="true"/>
        </managementContext>

        <networkConnectors>
            <networkConnector uri="static:(tcp://brokerB:61616)" duplex="true"/>
        </networkConnectors>
 
        <persistenceAdapter>
            <jdbcPersistenceAdapter dataSource="#pg-ds" useDatabaseLock="false">
                <statements>
                <statements messageTableName="amq_msg" lockTableName="amq_lock" durableSubAcksTableName="amq_acks"/>
                </statements>
            </jdbcPersistenceAdapter>
        </persistenceAdapter>

        <systemUsage>
            <systemUsage sendFailIfNoSpace="true">
                <memoryUsage>
                    <memoryUsage limit="512 mb"/>
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="10 gb"/>
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="1 gb"/>
                </tempUsage>
            </systemUsage>
        </systemUsage>
		  
        <transportConnectors>
            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
            <transportConnector name="stomp+nio" uri="stomp+nio://0.0.0.0:61613?transport.closeAsync=false"/>
        </transportConnectors>

    </broker>

    <bean id="pg-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.postgresql.Driver"/>
        <property name="url" value="jdbc:postgresql://10.10.10.10:5432/db"/>
        <property name="username" value="username"/>
        <property name="password" value="password"/>
        <property name="maxActive" value="10"/>
        <property name="poolPreparedStatements" value="true"/>
    </bean>

    <import resource="jetty.xml"/>
    
</beans>
  • 將 policyEntry queue 的 queuePrefetch 設為1,表示 Comsumer 一次只處理一個,處理完再拿下一個。
  • networkConnector 指定多台語法如下:
    <networkConnector uri="static://(tcp://brokerB:61616,tcp://brokerC:61616)" duplex="true"/>
  • transportConnector 多加 stomp+nio 協定
    <transportConnector name="stomp+nio" uri="stomp+nio://0.0.0.0:61613?transport.closeAsync=false"/>
  • 要啟動管理畫面就把 managementContext > createConnector 設為 true
    <managementContext createConnector="true"/>
  • 其它的幾 gb 幾 mb 都是我亂設定的,不知道這樣設對不對…


至此,算是架起來了吧,不過都有點瞎子摸象,還不是很瞭解…




0 comments:

張貼留言