incodehq / activemq-mssqlserver

ActiveMQ broker configured to use MS SQL Server as its backend persistence store.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

THIS PROJECT HAS BEEN ARCHIVED, AND MOVED TO A PRIVATE REPO ON gitlab.com

ActiveMQ on SQL Server

This project creates a Docker image of the ActiveMQ distribution, configured to run against SQL Server.

If run without any configuration, it falls back to using an in-memory HSQL database.

The Docker image of this app is available at Docker hub.

To allow configuration to be easily externalized, the image expects a /run/secrets directory to exist, and switches to and then runs the application in that directory. Spring Boot will then automatically pick up that configuration and use it.

Typically therefore all that is required is to define an spring.properties file as a secret.

Design

We run the activemq broker using an updated config, conf/activemq.xml. This takes the place of the default config, and is baked into the Docker image.

This replacement activemq.xml uses the PropertyPlaceholderConfigurer to read configuration property values (specifying the database URL etc) from an external properties file. The name of this file is specified using the spring.config.file system property.

The Docker image’s entrypoint (CMD, in fact) is entrypoint.sh, which runs the ActiveMQ console as follows:

activemq console -Dspring.config.file=file:/run/secrets/spring.properties

This assumes that the spring.properties has been mounted as a secret in /run/secrets.

However, if no /run/secrets/spring.properties can be found, then the script will automatically generate a fallback spring.properties to run with an in-memory HSQLDB database. This is useful if running adhoc/in development, outside of an orchestrator.

spring.properties

The format of spring.properties is:

spring.properties
activemq.data=activemq-data

activemq.db.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
activemq.db.url=jdbc:sqlserver://localhost:1433;instance=.;databaseName=activemq
activemq.db.username=activemq
activemq.db.password=activemq
activemq.db.jdbcAdapter=org.apache.activemq.store.jdbc.adapter.TransactJDBCAdapter
activemq.db.databaseLocker=org.apache.activemq.store.jdbc.adapter.TransactDatabaseLocker

Typically just the activemq.db.url, activemq.db.username and activemq.db.password properties need configuring; the rest can be left as is.

Running Locally

To run the Docker image locally, use:

export TAG=20191011.1912.master.880118bc

docker run -p61616:61616 -p8161:8161 incodehq/activemq-mssqlserver:$TAG

where $TAG is set to one of the images from the tags page.

This exposes :

The hard-coded password is admin/admin (from conf/users.properties, hard-coded into the image).

Further Reading

Additional info at:

About

ActiveMQ broker configured to use MS SQL Server as its backend persistence store.


Languages

Language:Dockerfile 75.7%Language:Shell 24.3%