2.2 Installation Steps
The installation steps are as follows:
1, decompression;
$ TAR-ZXVF apache-activemq-5.9.0-bin.tar.gz
$ cd/bin
$./activemq Start &
Start MQ in the Run Bin directory
2, related configuration, edit/conf/activemq.xml configuration file:
Master and slave Add the following same configuration:
<brokerxmlns= "Http://activemq.apache.org/schema/core" brokername= "localhost" datadirectory= "${activemq.data}" > <!--configuremessage persistence for the broker.
The default persistence mechanism isthe KAHADB Store (identified by the kahadb tag). For moreinformation, see:http://activemq.apache.org/persistence.html--<persistencead
apter> <!--<kahadbdirectory= "${activemq.data}/kahadb"/>-- <jdbcpersistenceadapterdatadirectory= "${activemq.data}/mysqldb" datasource= "#mySql" useDatabaseLock= "true"/ > </persistenceAdapter> </broker> <!--mysqldatasource-<beanid = "MYSQL" class= "Org.apache.commons.dbcp.BasicDataSource" > <propertyname= "driverclassname" value= " Com.mysql.jdbc.Driver "/> <propertyname=" url "value=" Jdbc:mysql://192.168.1.101:3306/activemq?relaXautocommit=true "/> <propertyname=" username "value=" root "/> <propertyname=" password "value=" ro
OT "/> <propertyname=" poolpreparedstatements "value=" true "/> </bean>
2. Start:
Execute/bin directory under ACTIVEMQ
./activemq Start &
3. View the log after startup:
Master:
Slave;
The previous log indicates a successful start.
2.3 Persistence Classification
There are three common ways of ACTIVEMQ persistence
1, kahadb file storage method;
2, the JDBC database storage method;
3 Persistence mode configuration 3.1 kahadb Configuration
1) Default Persistence configuration:
---------------------------------------------------------------------------------------------
<persistenceAdapter>
<kahadbdirectory= "${activemq.data}/kahadb"/>
</persistenceadapter >
By default, the KAHADB configuration is used; Data files are stored in the/data/directory
3.2 JDBC Database storage method
1) because the data needs to be persisted to the database, the corresponding database driver jar package needs to be put into the bin directory of ACTIVEMQ;
2) Description:
After persistence, 3 tables are generated in the database:
Activemq_acks
Activemq_lock
Activemq_msgs
3) Configuration:
XML code
Mysql:
<persistenceAdapter>
<jdbcpersistenceadapterdatadirectory= "${activemq.base}/data/mysqldb" Datasource= "#mySql"/>
</persistenceAdapter>
The MySQL data source is configured as follows:
<!--MySQL DataSource--
<beanid= "MySQL" class= "Org.apache.commons.dbcp.BasicDataSource" >
<propertyname= "Driverclassname" value= "Com.mysql.jdbc.Driver"/>
<propertyname= "url" value= "JDBC: Mysql://127.0.0.1:3306/activemq?relaxautocommit=true "/>
<propertyname=" username "value=" root "/>
<propertyname= "Password" value= "root"/>
<propertyname= "poolpreparedstatements" value= "true"/ >
</bean>
XML code
Oracle:
----------------------------------------------------------------------------------------------
<persistenceAdapter>
<jdbcpersistenceadapterdatasource= "#oracle-ds"/>
The Oracle data source is configured as follows:
XML code
<bean id= "Oracle-ds" class= "Org.apache.commons.dbcp.BasicDataSource" destroy-method= "Close" >
< Propertyname= "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= "$"/>
< Propertyname= "Poolpreparedstatements" value= "true"/>
Other data sources are configured to reference ACTIVEMQ documents.