activemq持久化配置,设置为主从模式(带复制的主从模式,应用mysql数据库)

activemq持久化配置,设置为主从模式(带复制的主从模式,应用mysql数据库)
2009年06月17日 星期三 10:41
别的不用多看罗,配置文件如下

<!--

LicensedtotheApacheSoftwareFoundation(ASF)underoneormore

contributorlicenseagreements.SeetheNOTICEfiledistributedwith

thisworkforadditionalinformationregardingcopyrightownership.

TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0

(the"License");youmaynotusethisfileexceptincompliancewith

theLicense.YoumayobtainacopyoftheLicenseat

http://www.apache.org/licenses/LICENSE-2.0

Unlessrequiredbyapplicablelaworagreedtoinwriting,software

distributedundertheLicenseisdistributedonan"ASIS"BASIS,

WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.

SeetheLicenseforthespecificlanguagegoverningpermissionsand

limitationsundertheLicense.

-->

<!--STARTSNIPPET:example-->

<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/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://activemq.apache.org/schema/corehttp://activemq.apache.org/schema/core/activemq-core.xsd

http://activemq.apache.org/camel/schema/springhttp://activemq.apache.org/camel/schema/spring/camel-spring.xsd">

<!--Allowsustousesystempropertiesasvariablesinthisconfigurationfile-->

<beanclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<propertyname="locations">

<value>file:///${activemq.base}/conf/credentials.properties</value>

</property>

</bean>

<!--下面红色字体是为了支持带数据库的主从模式集群的配置,被注释的蓝色字体是系统默认配置,单个activemq是用默认的.-->

<brokerxmlns="http://activemq.org/config/1.0"brokername="JdbcMasterBroker"persistent="true"useShutdownHook="false">

<!--<brokerxmlns="http://activemq.apache.org/schema/core"brokername="localhost"dataDirectory="${activemq.base}/data">-->

<!--Destinationspecificpoliciesusingdestinationnamesorwildcards-->

<destinationPolicy>

<policyMap>

<policyEntries>

<policyEntryqueue=">"memoryLimit="5mb"/>

<policyEntrytopic=">"memoryLimit="5mb">

<!--youcanaddotherpoliciestoosuchasthese

<dispatchPolicy>

<strictOrderDispatchPolicy/>

</dispatchPolicy>

<subscriptionRecoveryPolicy>

<lastImageSubscriptionRecoveryPolicy/>

</subscriptionRecoveryPolicy>

-->

</policyEntry>

</policyEntries>

</policyMap>

</destinationPolicy>

<!--UsethefollowingtoconfigurehowActiveMQisexposedinJMX-->

<managementContext>

<managementContextcreateConnector="false"/>

</managementContext>

<!--ThestoreandforwardbrokernetworksActiveMQwilllistento-->

<networkConnectors>

<!--bydefaultjustautodiscovertheotherbrokers-->

<!--<networkConnectorname="default-nc"uri="multicast://default"/>-->

<!--Exampleofastaticconfiguration:-->

<!--<networkConnectoruri="static://(tcp://localhost:61616,tcp://192.168.2.136:61616)"/>-->

</networkConnectors>

<!--下面的配置是和上面的“persistnet=true”相配合使用的。-->

<persistenceAdapter>

<amqPersistenceAdaptersyncOnWrite="false"directory="${activemq.base}/data"maxFileLength="20mb"/>

</persistenceAdapter>

<!--UsethefollowingifyouwishtoconfigurethejournalwithJDBC-->

<!--

<persistenceAdapter>

<journaledJDBCdataDirectory="${activemq.base}/data"dataSource="#postgres-ds"/>

</persistenceAdapter>

-->

<!--OrifyouwanttousepureJDBCwithoutajournal-->

<persistenceAdapter>

<jdbcPersistenceAdapterdataSource="#mysql-ds"/>

</persistenceAdapter>

<!--

<persistenceAdapter>

<jdbcPersistenceAdapterdataSource="#postgres-ds"/>

</persistenceAdapter>

-->

<sslContext>

<sslContextkeyStore="file:${activemq.base}/conf/broker.ks"keyStorePassword="password"trustStore="file:${activemq.base}/conf/broker.ts"trustStorePassword="password"/>

</sslContext>

<!--Themaximumaboutofspacethebrokerwillusebeforeslowingdownproducers-->

<systemUsage>

<systemUsage>

<memoryUsage>

<memoryUsagelimit="20mb"/>

</memoryUsage>

<storeUsage>

<storeUsagelimit="1gb"name="foo"/>

</storeUsage>

<tempUsage>

<tempUsagelimit="100mb"/>

</tempUsage>

</systemUsage>

</systemUsage>

<!--ThetransportconnectorsActiveMQwilllistento-->

<transportConnectors>

<transportConnectorname="openwire"uri="tcp://localhost:61616"

discoveryUri="multicast://default"/>

<transportConnectorname="ssl"uri="ssl://localhost:61617"/>

<transportConnectorname="stomp"uri="stomp://localhost:61613"/>

<transportConnectorname="xmpp"uri="xmpp://localhost:61222"/>

</transportConnectors>

</broker>

<!--

**LetsdeploysomeEnterpriseIntegrationPatternsinsidetheActiveMQMessageBroker

**Formoredetailssee

**

**http://activemq.apache.org/enterprise-integration-patterns.html

-->

<camelContextid="camel"xmlns="http://activemq.apache.org/camel/schema/spring">

<!--Youcanusea<package>elementforeachrootpackagetosearchforJavaroutes-->

<package>org.foo.bar</package>

<!--YoucanuseSpringXMLsyntaxtodefinetherouteshereusingthe<route>element-->

<route>

<fromuri="activemq:example.A"/>

<touri="activemq:example.B"/>

</route>

</camelContext>

<!--

**LetsconfiguresomeCamelendpoints

**

**http://activemq.apache.org/camel/components.html

-->

<!--configurethecamelactivemqcomponenttousethecurrentbroker-->

<beanid="activemq"class="org.apache.activemq.camel.component.ActiveMQComponent">

<propertyname="connectionFactory">

<beanclass="org.apache.activemq.ActiveMQConnectionFactory">

<propertyname="brokerURL"value="vm://localhost?create=false&amp;waitForStart=10000"/>

<propertyname="userName"value="${activemq.username}"/>

<propertyname="password"value="${activemq.password}"/>

</bean>

</property>

</bean>

<!--UncommenttocreateacommandagenttorespondtomessagebasedadmincommandsontheActiveMQ.Agenttopic-->

<!--

<commandAgentxmlns="http://activemq.apache.org/schema/core"brokerUrl="vm://localhost"username="${activemq.username}"password="${activemq.password}"/>

-->

<!--AnembeddedservletengineforservinguptheAdminconsole-->

<jettyxmlns="http://mortbay.com/schemas/jetty/1.0">

<connectors>

<nioConnectorport="8161"/>

</connectors>

<handlers>

<webAppContextcontextPath="/admin"resourceBase="${activemq.base}/webapps/admin"logUrlOnStart="true"/>

<webAppContextcontextPath="/demo"resourceBase="${activemq.base}/webapps/demo"logUrlOnStart="true"/>

<webAppContextcontextPath="/fileserver"resourceBase="${activemq.base}/webapps/fileserver"logUrlOnStart="true"/>

</handlers>

</jetty>

<!--Thisxbeanconfigurationfilesupportsallthestandardspringxmlconfigurationoptions-->

<!--PostgresDataSourceSampleSetup-->

<!--

<beanid="postgres-ds"class="org.postgresql.ds.PGPoolingDataSource">

<propertyname="serverName"value="localhost"/>

<propertyname="databaseName"value="activemq"/>

<propertyname="portNumber"value="0"/>

<propertyname="user"value="activemq"/>

<propertyname="password"value="activemq"/>

<propertyname="dataSourceName"value="postgres"/>

<propertyname="initialConnections"value="1"/>

<propertyname="maxConnections"value="10"/>

</bean>

-->

<!--MySqlDataSourceSampleSetup-->

<beanid="mysql-ds"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close">

<propertyname="driverClassName"value="com.mysql.jdbc.Driver"/>

<propertyname="url"value="jdbc:mysql://192.168.2.136:3306/activemq?relaxAutoCommit=true"/>

<propertyname="username"value="app"/>

<propertyname="password"value="app"/>

<propertyname="maxActive"value="200"/>

<propertyname="poolPreparedStatements"value="true"/>

</bean>

<!--OracleDataSourceSampleSetup-->

<!--

<beanid="oracle-ds"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close">

<propertyname="driverClassName"value="oracle.jdbc.driver.OracleDriver"/>

<propertyname="url"value="jdbc:oracle:thin:@localhost:1521:AMQDB"/>

<propertyname="username"value="scott"/>

<propertyname="password"value="tiger"/>

<propertyname="maxActive"value="200"/>

<propertyname="poolPreparedStatements"value="true"/>

</bean>

-->

<!--EmbeddedDerbyDataSourceSampleSetup-->

<!--

<beanid="derby-ds"class="org.apache.derby.jdbc.EmbeddedDataSource">

<propertyname="databaseName"value="derbydb"/>

<propertyname="createDatabase"value="create"/>

</bean>

-->

</beans>

<!--ENDSNIPPET:example-->

已主从模式运行(192.168.2.137为主,192.168.2.136为从),还需在客户端上运行如下命令:

java.naming.provider.url=failover:(tcp://192.168.2.137:61616,tcp://192.168.2.136:61616)?

randomize=false#没有这一行的话,就变成了networksofbrokers

initialReconnectDelay=10#这里的单位是毫秒

activemq的目录里有个example,只要简单配置一下build.xml,即可测试activemq的message的consume和query

<projectname="Inbox"default="help"basedir=".">

<propertyname="class.dir"value="target/classes"/>

<propertyname="activemq.home"value=".."/>

<!--作为消息consume的使用本地地址,作为消息query的使用consumer的ip地址-->

<!--exampleprogramdefaults-->

<propertyname="url"value="tcp://localhost:61616"/>

相关推荐