docker.recipes

ActiveMQ

beginner

Popular open-source message broker.

Overview

Apache ActiveMQ is a mature, Java-based open-source message broker that has been a cornerstone of enterprise messaging since 2004. It implements the Java Message Service (JMS) specification and provides reliable message queuing, pub/sub messaging, and advanced routing capabilities for distributed applications. ActiveMQ supports multiple protocols including OpenWire, STOMP, AMQP, and MQTT, making it versatile for heterogeneous environments where different applications need to communicate asynchronously. This Docker deployment provides a complete ActiveMQ Classic instance with persistent message storage and access to both the messaging engine and web-based management console. The setup exposes the primary OpenWire protocol on port 61616 for JMS clients, while the web console on port 8161 allows administrators to monitor queues, topics, connections, and message flow in real-time. The persistent volume ensures message durability across container restarts, critical for production messaging scenarios. Development teams building microservices architectures, system integrators connecting legacy applications, and enterprises implementing event-driven architectures will find this deployment particularly valuable. ActiveMQ excels in scenarios requiring guaranteed message delivery, complex routing patterns, and integration with Java-based applications, while also supporting lightweight protocols for IoT devices and web applications through STOMP and MQTT.

Key Features

  • JMS 1.1 compliant message broker supporting both point-to-point queues and publish-subscribe topics
  • Multi-protocol support including OpenWire, STOMP, AMQP 1.0, and MQTT for diverse client connectivity
  • Web-based administration console with real-time monitoring of queues, topics, connections, and message statistics
  • Message persistence with configurable storage adapters ensuring durability across restarts
  • Virtual destinations enabling complex routing patterns and message transformation
  • Message groups for ordered processing and exclusive consumers for load balancing
  • Network of brokers capability for clustering and high availability deployments
  • Dead letter queue handling for failed message processing and poison message management

Common Use Cases

  • 1Microservices communication requiring reliable asynchronous messaging between distributed components
  • 2Enterprise application integration connecting legacy systems with modern applications
  • 3Event-driven architectures implementing CQRS patterns and event sourcing
  • 4IoT device communication using MQTT protocol for sensor data collection and device control
  • 5Batch processing systems requiring job queue management and work distribution
  • 6Real-time notification systems for web applications using STOMP over WebSockets
  • 7Financial services implementing trade processing and settlement workflows with guaranteed delivery

Prerequisites

  • Docker Engine 20.10+ and Docker Compose V2 for container orchestration
  • Minimum 512MB RAM allocated to Docker for basic ActiveMQ operations
  • Available ports 8161 and 61616 on the host system for web console and JMS connectivity
  • Basic understanding of message queuing concepts including queues, topics, and JMS
  • Java development knowledge if building custom JMS clients or message processors
  • Network access planning for client applications connecting to the message broker

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 activemq:
3 image: apache/activemq-classic:latest
4 container_name: activemq
5 restart: unless-stopped
6 volumes:
7 - activemq_data:/opt/activemq/data
8 ports:
9 - "61616:61616"
10 - "8161:8161"
11
12volumes:
13 activemq_data:

.env Template

.env
1# Default credentials: admin / admin

Usage Notes

  1. 1Docs: https://activemq.apache.org/components/classic/documentation
  2. 2Web console at http://localhost:8161/admin, default: admin/admin
  3. 3JMS/OpenWire on port 61616, AMQP on 5672, STOMP on 61613
  4. 4Supports queues (point-to-point) and topics (pub/sub)
  5. 5Create destinations via web console or on first use
  6. 6Enterprise features: message groups, virtual destinations, network of brokers

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 activemq:
5 image: apache/activemq-classic:latest
6 container_name: activemq
7 restart: unless-stopped
8 volumes:
9 - activemq_data:/opt/activemq/data
10 ports:
11 - "61616:61616"
12 - "8161:8161"
13
14volumes:
15 activemq_data:
16EOF
17
18# 2. Create the .env file
19cat > .env << 'EOF'
20# Default credentials: admin / admin
21EOF
22
23# 3. Start the services
24docker compose up -d
25
26# 4. View logs
27docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/activemq/run | bash

Troubleshooting

  • OutOfMemoryError in ActiveMQ logs: Increase Docker container memory limits and configure ActiveMQ heap size via ACTIVEMQ_OPTS environment variable
  • Web console shows 'admin/admin login failed': Check if default credentials were changed or container logs for authentication errors
  • JMS clients cannot connect on port 61616: Verify firewall settings and ensure the OpenWire transport connector is enabled in ActiveMQ configuration
  • Messages not persisting after container restart: Confirm the activemq_data volume is properly mounted and has write permissions
  • High CPU usage with message buildup: Check for slow consumers and configure message cursors or implement dead letter queue policies
  • STOMP/MQTT connections failing: Ensure additional transport connectors are configured for these protocols beyond the default OpenWire

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space