Apache ActiveMQ (now referred to as "Classic") and ActiveMQ Artemis represent two generations of message brokers with fundamentally different architectures. While Artemis began as a subproject to eventually replace Classic, both now coexist with independent release cycles due to enterprise adoption patterns.
// Classic ActiveMQ (5.x) | // Artemis (2.x+)
Broker broker = new BrokerService(); | ServerLocator locator = ActiveMQClient
broker.addConnector("tcp://localhost:61616"); | .createServerLocator("tcp://localhost:61616");
broker.start(); | ClientSessionFactory factory = locator.createSessionFactory();
| ClientSession session = factory.createSession();
Artemis demonstrates 10x higher throughput in persistent messaging scenarios due to:
- Journal-based storage (vs Classic's KahaDB)
- Lock-free threading model
- Zero-copy message buffering
// JMS 2.0 Delivery Delay (Artemis only)
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryDelay(5000); // 5-second delay
// JMS 2.0 Async Send (Both support)
producer.sendAsync(message, new CompletionListener() {
@Override
public void onCompletion(Message message) {
System.out.println("Message confirmed");
}
});
Key factors when choosing:
Criteria | Classic ActiveMQ | Artemis |
---|---|---|
Legacy System Integration | Better | Requires adapters |
HA Configuration | Master/Slave | Shared Store or Replication |
Protocol Support | OpenWire, STOMP | AMQP, MQTT, STOMP |
# Artemis broker.xml snippet
<addresses>
<address name="orders">
<multicast>
<queue name="fulfillment"/>
<queue name="billing"/>
</multicast>
</address>
</addresses>
# vs Classic activemq.xml
<destinationInterceptors>
<virtualDestinationInterceptor>
<virtualDestinations>
<compositeQueue name="orders">
<forwardTo>
<queue physicalName="fulfillment"/>
<queue physicalName="billing"/>
</forwardTo>
</compositeQueue>
</virtualDestinations>
</virtualDestinationInterceptor>
</destinationInterceptors>
Artemis introduces:
// Artemis Metrics via Jolokia
curl http://localhost:8161/console/jolokia/read/org.apache.activemq.artemis:broker=\"0.0.0.0\"/MessageCount
// Classic JMX
ObjectName name = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Broker");
MBeanServerConnection conn = ManagementFactory.getPlatformMBeanServer();
conn.getAttribute(name, "TotalMessageCount");
Artemis simplifies scaling:
<cluster-connections>
<cluster-connection name="my-cluster">
<connector-ref>netty-connector</connector-ref>
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<static-connectors>
<connector-ref>server1-connector</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>
The Apache ActiveMQ ecosystem currently exists in two parallel implementations:
- ActiveMQ "Classic" (v5.x): The original implementation with 15+ years of production history
- ActiveMQ Artemis (v2.x): A high-performance rewrite based on HornetQ codebase
// Classic ActiveMQ connection factory
ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
// Artemis connection factory
ConnectionFactory factory = new ActiveMQConnectionFactory(
"tcp://localhost:61616",
"admin",
"password");
Key technical distinctions:
Feature | ActiveMQ Classic | Artemis |
---|---|---|
Protocols | OpenWire, STOMP, AMQP, MQTT | Core Protocol, AMQP, STOMP, MQTT |
Persistence | KahaDB, JDBC | Journal-based with NIO |
JMS Support | JMS 1.1 | JMS 2.0 |
Artemis demonstrates significant improvements in:
- Message throughput (2-5x higher in our tests)
- Lower latency (especially under heavy load)
- More efficient memory usage
// Artemis address configuration example
<address name="orders.queue">
<anycast>
<queue name="orders"/>
</anycast>
</address>
When moving from Classic to Artemis:
- Review protocol compatibility (OpenWire vs Core Protocol)
- Adapt configuration files (artemis.xml vs activemq.xml)
- Test client connection patterns
- Verify persistence migration tools
For new deployments:
- Choose Artemis if you need JMS 2.0, higher performance, or plan for long-term support
- Consider Classic only for legacy system compatibility
The Apache Foundation has stated that Artemis will eventually replace Classic, though no official EOL date exists for Classic yet.