1. Ports
  2. Port 61616

Every enterprise system eventually faces the same problem: how do you get two systems to talk when one might be asleep?

Port 61616 is the answer that Apache ActiveMQ provides. It's the default port for the OpenWire protocol, a binary wire format designed to carry messages between systems that might not be running at the same time, might not speak the same language, and might not even know each other exists.

What Port 61616 Does

When a client connects to port 61616, it's connecting to an ActiveMQ message broker.1 The broker acts as an intermediary: it accepts messages from producers, stores them safely, and delivers them to consumers when they're ready to receive them.

The default transport configuration looks like this:

<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>

A Java client connecting to the broker is as simple as:

ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://broker.example.com:61616");
Connection connection = factory.createConnection();

Starting with ActiveMQ 5.13.0, port 61616 gained automatic protocol detection. The same port can handle OpenWire, STOMP, AMQP, and MQTT traffic, with the broker detecting which protocol the client speaks.2 This means a single port can serve Java applications using OpenWire, Python scripts using STOMP, IoT devices using MQTT, and cloud services using AMQP.

The OpenWire Protocol

OpenWire is a binary protocol designed for speed and JMS compliance.3 Unlike text-based protocols like STOMP, OpenWire uses compact binary serialization that minimizes bandwidth while maintaining full Java Message Service (JMS) semantics.

The protocol follows the Command Pattern: clients and brokers exchange Command objects, each representing an action like creating a connection, sending a message, or acknowledging receipt.4 When a client first connects, it sends a WireFormatInfo command describing the protocol version it supports. The broker and client negotiate the highest version both can handle, maintaining backward compatibility across different ActiveMQ releases.

The protocol is largely asynchronous, using fire-and-forget messaging for most operations. But when confirmation is critical, like when establishing a connection or receiving acknowledgment that a message was persisted, OpenWire supports request-response patterns with correlated message IDs.

For connection health monitoring, OpenWire includes inactivity detection. By default, if no data crosses the connection for 30 seconds, the broker assumes the client has disconnected and cleans up resources.5

The Problem ActiveMQ Solved

Before enterprise message brokers became common, distributed systems faced what engineers call "temporal coupling": both the sender and receiver had to be running at the same time for communication to work.6

Consider an e-commerce system: when a customer places an order, the web frontend needs to notify the inventory system, the payment processor, the shipping system, and the email service. With direct connections, if any of these systems is down for maintenance or overwhelmed with traffic, the order fails. The customer sees an error. Revenue is lost.

Message brokers break this coupling. The web frontend sends a message to the broker and immediately returns success to the customer. The broker guarantees the message will be delivered, whether that takes milliseconds or hours. The inventory system processes orders when it's ready. The email service catches up after its maintenance window. No messages are lost.

This is what IBM calls "message-oriented middleware" (MOM), and it's the architectural pattern that makes modern microservices possible.7

The Birth of ActiveMQ

In 2004, a team at a startup called LogicBlaze set out to build an open-source alternative to expensive commercial message brokers like IBM's WebSphere MQ and TIBCO's EMS.8

The founders included James Strachan, who had already created the Groovy programming language, dom4j, and contributed to Apache Geronimo, and Hiram Chirino, who would later become the PMC Chair for the Apache ActiveMQ project.9 They were believers in open source and frustrated that enterprise messaging was locked behind expensive licenses.

LogicBlaze operated for 18 months before being acquired by IONA Technologies in 2007.10 As part of the acquisition, the ActiveMQ codebase and trademark were donated to the Apache Software Foundation. The project has lived there ever since, maintained by an active community and backed by enterprise support from companies like Red Hat (through AMQ Broker) and Amazon (through Amazon MQ).11

How OpenWire Actually Works

When you trace a message through port 61616, here's what happens on the wire:

  1. Connection Setup: The client sends a WireFormatInfo command declaring its protocol version and capabilities. The broker responds with its own WireFormatInfo, and they settle on the highest mutually supported version.

  2. Authentication: The client sends a ConnectionInfo command containing the hostname, username, password, and a unique client ID. The broker validates credentials and responds with a Response indicating success or failure.

  3. Session Creation: The client creates a session by sending a SessionInfo command. Sessions provide transactional boundaries and acknowledgment management.

  4. Message Production: When a producer sends a message, it's wrapped in a Message command containing the destination, headers, properties, and payload. For persistent messages, the broker writes to its message store (KahaDB by default) before acknowledging.

  5. Message Consumption: Consumers receive messages via MessageDispatch commands. When they're done processing, they send MessageAck commands to confirm delivery.

The entire dance is optimized for throughput. OpenWire supports prefetching (the broker proactively sends messages to consumers before they ask), batching (multiple operations in a single network round-trip), and compression (reducing payload size for large messages).12

Security: The 2023 Wake-Up Call

On October 25, 2023, Apache disclosed CVE-2023-46604, a critical remote code execution vulnerability in ActiveMQ.13 The vulnerability allowed attackers with network access to port 61616 to execute arbitrary shell commands by manipulating serialized class types in the OpenWire protocol.

The attack exploited ClassPathXmlApplicationContext, a Spring Framework class bundled with ActiveMQ that can load XML configuration files over HTTP. Attackers crafted malicious EXCEPTION_RESPONSE commands that caused the broker to instantiate this class with a URL pointing to attacker-controlled XML containing embedded code.14

The vulnerability was devastating for two reasons:

First, exploitation was trivially easy. Proof-of-concept code appeared within days, and a Metasploit module automated the entire attack.15

Second, attackers were already exploiting it before the disclosure. Cybereason researchers found attacks dating back to October 11, 2023, two weeks before the CVE was published.16 The HelloKitty ransomware gang, whose source code had leaked in early October, was among the first to weaponize the vulnerability.

The affected versions span years of releases:

  • ActiveMQ 5.18.0 before 5.18.3
  • ActiveMQ 5.17.0 before 5.17.6
  • ActiveMQ 5.16.0 before 5.16.7
  • ActiveMQ before 5.15.16

Organizations that hadn't patched saw their brokers compromised, with attackers deploying ransomware, cryptocurrency miners, and backdoors like SparkRAT.17

The lesson was brutal: any service exposed on port 61616 must be behind a firewall, properly authenticated, and kept current with security patches. The efficiency that made OpenWire fast, its ability to deserialize objects directly from the wire, was the same feature that made it dangerous.

ActiveMQ Today

ActiveMQ remains one of the most widely deployed message brokers. Over 8,600 companies use it, commanding approximately 4.6% of the enterprise application integration market.18

The ActiveMQ family now includes two main variants:

ActiveMQ "Classic": The original broker, stable and battle-tested, running the OpenWire protocol on port 61616 by default.

ActiveMQ Artemis: The "next generation" broker, based on the HornetQ codebase donated by JBoss in 2015.19 Artemis introduces a new Core protocol while maintaining full backward compatibility with OpenWire clients. It offers improved performance, better clustering, and enhanced protocol support.

For cloud deployments, Amazon MQ provides managed ActiveMQ instances that handle provisioning, patching, and high availability automatically.20 Red Hat AMQ Broker offers enterprise support and integration with OpenShift.

Port 61616 is the primary entry point for ActiveMQ, but the broker uses several other ports:

PortProtocolPurpose
61616TCPOpenWire, STOMP, AMQP, MQTT (auto-detected)
8161HTTPWeb console and management interface
61613TCPSTOMP protocol (dedicated)
5672TCPAMQP protocol (dedicated)
1883TCPMQTT protocol (dedicated)
61617TCPOpenWire over SSL

Frequently Asked Questions

Was this page helpful?

😔
🤨
😃