ACTIVEMQ persistent configuration, set as primary slave mode (with copy master-slave mode, apply MySQL database)

Source: Internet
Author: User
Tags stomp enterprise integration patterns

The configuration file is as follows
<!--
Licensed to the Apache software Foundation (ASF) under one or more
Contributor license agreements. See the NOTICE file distributed with
This is for additional information regarding copyright ownership.
The ASF licenses this file to you under the Apache License, Version 2.0
(the "License"); Except in compliance with
The License. Obtain a copy of the License at

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

Unless required by applicable law or agreed to writing, software
Distributed under the License is distributed on a "as is" BASIS,
Without warranties or CONDITIONS of any KIND, either express or implied.
See the License for the specific language governing permissions and
Limitations under the License.
-
<!--START Snippet: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/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
Http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd " >

<!--allows us to use system properties as variables on 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 following red font is to support the configuration of the master-slave cluster with the database, the commented blue font is the system default configuration, and a single activemq is used by default. -
<broker xmlns= "http://activemq.org/config/1.0" brokername= "Jdbcmasterbroker" persistent= "true" useshutdownhook= "False" >

<!--<broker xmlns= "http://activemq.apache.org/schema/core" brokername= "localhost" datadirectory= "${ Activemq.base}/data ">

<!--Destination specific policies using Destination names or wildcards-
<destinationPolicy>
<policyMap>
<policyEntries>
<policyentry queue= ">" memorylimit= "5MB"/>
<policyentry topic= ">" memorylimit= "5MB" >
<!--can add other policies too such as these
<dispatchPolicy>
<strictOrderDispatchPolicy/>
</dispatchPolicy>
<subscriptionRecoveryPolicy>
<lastImageSubscriptionRecoveryPolicy/>
</subscriptionRecoveryPolicy>
-
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>

<!--Use the following to configure how ActiveMQ are exposed in JMX--
<managementContext>
<managementcontext createconnector= "false"/>
</managementContext>

<!--the store and forward broker networks ActiveMQ would listen to
<networkConnectors>
<!--by default just auto discover the other brokers--
<!--<networkconnector name= "Default-nc" uri= "Multicast://default"/>--
<!--Example of a static configuration:-->
<!--<networkconnector uri= "static://(tcp://localhost:61616,tcp://192.168.2.136:61616)"/>-->

</networkConnectors>
<!--The following configuration is used in conjunction with the "Persistnet=true" above. -
<persistenceAdapter>
<amqpersistenceadapter synconwrite= "false" directory= "${activemq.base}/data" maxfilelength= "MB"/>
</persistenceAdapter>

<!--Use the following if wish to configure the journal with JDBC--
<!--
<persistenceAdapter>
<journaledjdbc datadirectory= "${activemq.base}/data" datasource= "#postgres-ds"/>
</persistenceAdapter>
-

<!--Or If you want to use pure JDBC without a journal-
<persistenceAdapter>
<jdbcpersistenceadapter datasource= "#mysql-ds"/>
</persistenceAdapter>
<!--
<persistenceAdapter>
<jdbcpersistenceadapter datasource= "#postgres-ds"/>
</persistenceAdapter>
-

<sslContext>
<sslcontext keystore= "FILE:${ACTIVEMQ.BASE}/CONF/BROKER.KS" keystorepassword= "password" trustStore= "file:${ Activemq.base}/conf/broker.ts "truststorepassword=" password "/>
</sslContext>

<!--the maximum about space the broker would use before slowing down producers-
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryusage limit= "MB"/>
</memoryUsage>
<storeUsage>
<storeusage limit= "1 GB" name= "foo"/>
</storeUsage>
<tempUsage>
<tempusage limit= "MB"/>
</tempUsage>
</systemUsage>
</systemUsage>


<!--the transport connectors ActiveMQ would listen to
<transportConnectors>
<transportconnector name= "Openwire" uri= "tcp://localhost:61616"
discoveryuri= "Multicast://default"/>
<transportconnector name= "SSL" uri= "ssl://localhost:61617"/>
<transportconnector name= "Stomp" uri= "stomp://localhost:61613"/>
<transportconnector name= "XMPP" uri= "xmpp://localhost:61222"/>
</transportConnectors>

</broker>

<!--
* * Lets Deploy some Enterprise integration Patterns inside the ActiveMQ Message Broker
* * For more details see
**
* * http://activemq.apache.org/enterprise-integration-patterns.html
-
<camelcontext id= "Camel" xmlns= "http://activemq.apache.org/camel/schema/spring" >

<!--you can use a <package> element for each root package to search for Java routes---
<package>org.foo.bar</package>

<!--you can use Spring XML syntax to define the routes here using the <route> element--
<route>
<from uri= "Activemq:example. A "/>
<to uri= "Activemq:example. B "/>
</route>
</camelContext>

<!--
* * Lets Configure some Camel endpoints
**
* * http://activemq.apache.org/camel/components.html
-

<!--Configure the Camel ACTIVEMQ component to use the current broker---
<bean id= "Activemq" class= "Org.apache.activemq.camel.component.ActiveMQComponent" >
<property name= "ConnectionFactory" >
<bean class= "Org.apache.activemq.ActiveMQConnectionFactory" >
<property name= "Brokerurl" value= "vm://localhost?create=false&amp;waitforstart=10000"/>
<property name= "UserName" value= "${activemq.username}"/>
<property name= "Password" value= "${activemq.password}"/>
</bean>
</property>
</bean>



<!--uncomment to create a command agent to respond to message based admin commands on the activemq.agent topic-
<!--
<commandagent xmlns= "Http://activemq.apache.org/schema/core" brokerurl= "Vm://localhost" Username= "${ Activemq.username} "password=" ${activemq.password} "/>
-


<!--a embedded servlet engine for serving up the Admin console--
<jetty xmlns= "http://mortbay.com/schemas/jetty/1.0" >
<connectors>
<nioconnector port= "8161"/>
</connectors>

<webappcontext contextpath= "/admin" resourcebase= "${activemq.base}/webapps/admin" logUrlOnStart= "true"/>
<webappcontext contextpath= "/demo" resourcebase= "${activemq.base}/webapps/demo" logUrlOnStart= "true"/>
<webappcontext contextpath= "/fileserver" resourcebase= "${activemq.base}/webapps/fileserver" logUrlOnStart= " True "/>
</jetty>

<!--This xbean configuration, file supports all, the standard spring XML configuration Options--

<!--Postgres DataSource Sample Setup--
<!--
<bean id= "Postgres-ds" class= "Org.postgresql.ds.PGPoolingDataSource" >
<property name= "serverName" value= "localhost"/>
<property name= "DatabaseName" value= "Activemq"/>
<property name= "portnumber" value= "0"/>
<property name= "user" value= "activemq"/>
<property name= "Password" value= "Activemq"/>
<property name= "DataSourceName" value= "Postgres"/>
<property name= "Initialconnections" value= "1"/>
<property name= "MaxConnections" value= "ten"/>
</bean>
-

<!--MySql DataSource Sample Setup--

<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://192.168.2.136:3306/activemq?relaxautocommit=true"/>
<property name= "username" value= "app"/>
<property name= "password" value= "app"/>
<property name= "maxactive" value= "/>"
<property name= "Poolpreparedstatements" value= "true"/>
</bean>


<!--Oracle DataSource Sample Setup--
<!--
<bean id= "Oracle-ds" class= "Org.apache.commons.dbcp.BasicDataSource" destroy-method= "Close" >
<property name= "Driverclassname" value= "Oracle.jdbc.driver.OracleDriver"/>
<property name= "url" value= "Jdbc:oracle:thin: @localhost: 1521:amqdb"/>
<property name= "username" value= "Scott"/>
<property name= "password" value= "Tiger"/>
<property name= "maxactive" value= "/>"
<property name= "Poolpreparedstatements" value= "true"/>
</bean>
-

<!--Embedded Derby DataSource Sample Setup--
<!--
<bean id= "Derby-ds" class= "Org.apache.derby.jdbc.EmbeddedDataSource" >
<property name= "DatabaseName" value= "Derbydb"/>
<property name= "CreateDatabase" value= "create"/>
</bean>
-

</beans>
<!--END Snippet:example--

Master-Slave mode is running (192.168.2.137-based, 192.168.2.136 is from), and you need to run the following command on the client:
Java.naming.provider.url=failover: (tcp://192.168.2.137:61616,tcp://192.168.2.136:61616)?
Randomize=false # Without this line, it becomes networks of brokers
INITIALRECONNECTDELAY=10 # The units here are milliseconds




There is a example in the ACTIVEMQ directory, so you can test consume and query for ACTIVEMQ's message with a simple configuration of build.xml
<project name= "Inbox" default= "Help" basedir= "." >

<property name= "Class.dir" value= "target/classes"/>
<property name= "Activemq.home" value= "..." />
<!--use local address as message consume, use consumer IP address as message query--
<!--Example program defaults--
<property name= "url" value= "tcp://localhost:61616"/>

ACTIVEMQ persistent configuration, set as primary slave mode (with copy master-slave mode, apply MySQL database)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.