Apache ActiveMQ Simple configuration for persistent to MySQL database

Source: Internet
Author: User

1. Preface

ActiveMQ is the most popular, powerful, open source messaging bus that Apache has produced. ActiveMQ is a JMS provider implementation that fully supports the JMS1.1 and the Java EE 1.4 specification, although the JMS specification has been around for a long time, but JMS still plays a special role in the middle of today's Java EE applications.

For more information about ACTIVEMQ, please refer to:Http://baike.baidu.com/view/433374.htm?fr=aladdin

For more information on JMS, please refer to:Http://baike.baidu.com/subview/157103/12665866.htm?fr=aladdin

ACTIVEMQ provides a variety of data persistence methods: It can be persisted to a file, or it can be persisted to a database, where the database can support two types of MySQL and Oracle.

The default is to persist to a file in a way that is in the Activemq.xml file:

<persistenceAdapter>

<KAHADB directory= "${activemq.base}/data/kahadb"/>

</persistenceAdapter>

2. Steps

The focus of this article is on how to configure persistence to MySQL:

2.1 Adding MySQL Drivers

First need to put the MySQL driver into the activemq Lib directory, I use the file name is: Mysql-connector-java-5.1.30-bin.jar

2.2 Modifying the configuration file Activemq.xml

This section of the configuration will be:

<persistenceAdapter>
<KAHADB directory= "${activemq.base}/data/kahadb"/>
</persistenceAdapter>

Modify it to the following paragraph:

<persistenceAdapter>

<jdbcpersistenceadapter datasource= "#derby-ds"/>

</persistenceAdapter>

It is also necessary to define a bean with ID derby-ds above the broker node, as follows:

<beanid= "Derby-ds" class= "Org.apache.commons.dbcp.BasicDataSource" destroy-method= "Close" >

<propertyname= "Driverclassname" value= "Com.mysql.jdbc.Driver"/>

<property name= "url" value= "Jdbc:mysql://localhost:3306/test_mq?relaxautocommit=true"/>

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

<propertyname= "Password" value= "root"/>

<propertyname= "maxactive" value= "/>"

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

</bean>

2.3 New Database

As you can see from the configuration, the name of the database is TEST_MQ and you need to manually create a new TEST_MQ empty database in MySQL.

At this point, restart MQ, you will find the TEST_MQ library more than three tables: Activemq_acks,activemq_lock,activemq_msgs,ok, the description has been persistent success!



Apache ActiveMQ Simple configuration for persistent to 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.