Use SpringBoot to Deploy ActiveMQ Broker to Tomcat-2/3

This post is to continue the first part of the same topic. It mainly covers:

  1. Use commercial database as the data store
  2. Use the embedded Tomcat to manage the data source connection pool


Despite the fact that the ActiveMQ buildin Kaha database is more efficient when handling messages, we sometimes need to take other consideration too. For example, if your production environment prefers to database based backup and disaster recovery than NAS, you have to consider database.

Use MS-SQL-Server as the data store

There are many ways to create a datasource for ActiveMQ. This post creates one with SpringBoot and pass it to Tomcat for pool management.

Step#1: Add dependency spring-boot-starter-jdbc into the build file, and then add the following section into the file

Step#2: Disable broker auto-start. You need to ensure the broker is started after the data source is injected. This is done by calling


in the SpringBoot main() method, and then explicitly start it after setting the persistent adapter for the broker:


Use Tomcat to manage the connection pool

This can be easily done by adding the following into file

#Tomcat connection pool
spring.datasource.tomcat.validation_query=SELECT 1

Source Code

The source code can be viewed or downloaded from here.

Special Notes

You may see build error due to missing mssql jdbc driver. You need to specify your repository that hosts the driver artifact, or put it into your local gradle cache.

You can find the next related post here.

This entry was posted in Java and tagged , , , , . Bookmark the permalink.

1 Response to Use SpringBoot to Deploy ActiveMQ Broker to Tomcat-2/3

  1. Pingback: Use SpringBoot to Deploy ActiveMQ Broker to Tomcat 1/2 | SW Notes

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s