or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

actors.mdcollections.mdcore-api.mdexceptions.mdindex.mdjson-api.mdlogging.mdutilities.md
tile.json

tessl/maven-org-apache-activemq--artemis-commons

Common utilities, API classes, and shared functionality for Apache ActiveMQ Artemis message broker

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.apache.activemq/artemis-commons@2.42.x

To install, run

npx @tessl/cli install tessl/maven-org-apache-activemq--artemis-commons@2.42.0

index.mddocs/

Apache ActiveMQ Artemis Commons

Apache ActiveMQ Artemis Commons provides essential common utilities, API classes, exception definitions, and shared functionality for the Apache ActiveMQ Artemis message broker ecosystem. This library serves as the foundational layer containing core APIs, utility classes, JSON processing capabilities, and shared data structures that other Artemis components depend upon.

Package Information

  • Package Name: org.apache.activemq:artemis-commons
  • Package Type: maven
  • Language: Java
  • Installation: Add to Maven POM:
    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>artemis-commons</artifactId>
      <version>2.42.0</version>
    </dependency>

Core Imports

// Core API classes
import org.apache.activemq.artemis.api.core.QueueConfiguration;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.RoutingType;

// Exception handling
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;

// Utilities
import org.apache.activemq.artemis.utils.ByteUtil;
import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
import org.apache.activemq.artemis.utils.FileUtil;
import org.apache.activemq.artemis.utils.TimeUtils;
import org.apache.activemq.artemis.utils.UTF8Util;
import org.apache.activemq.artemis.utils.UUID;
import org.apache.activemq.artemis.utils.UUIDGenerator;

// Collections
import org.apache.activemq.artemis.utils.collections.TypedProperties;
import org.apache.activemq.artemis.utils.collections.ConcurrentLongHashMap;
import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet;
import org.apache.activemq.artemis.utils.collections.LinkedListImpl;

// Actor Framework
import org.apache.activemq.artemis.utils.actors.Actor;
import org.apache.activemq.artemis.utils.actors.ThresholdActor;
import org.apache.activemq.artemis.utils.actors.OrderedExecutor;

// JSON API (shaded)
import org.apache.activemq.artemis.json.JsonObject;
import org.apache.activemq.artemis.json.JsonArray;
import org.apache.activemq.artemis.utils.JsonLoader;

Basic Usage

import org.apache.activemq.artemis.api.core.QueueConfiguration;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.RoutingType;

// Create a queue configuration with fluent API
QueueConfiguration queueConfig = QueueConfiguration.of("myQueue")
    .setAddress(SimpleString.of("myAddress"))
    .setRoutingType(RoutingType.ANYCAST)
    .setDurable(true)
    .setMaxConsumers(10);

// Convert to JSON
String jsonString = queueConfig.toJSON();

// Create from JSON
QueueConfiguration fromJson = QueueConfiguration.fromJSON(jsonString);

// Work with SimpleString for performance
SimpleString address = SimpleString.of("my.address.name");
boolean isMatch = address.startsWith(SimpleString.of("my."));

Architecture

Artemis Commons is organized into several key architectural layers:

  • Core API Layer (org.apache.activemq.artemis.api.core): Primary API classes for queue configuration, buffer operations, and core data types
  • Utilities Layer (org.apache.activemq.artemis.utils): Threading, pooling, validation, and general-purpose utilities
  • JSON Layer (org.apache.activemq.artemis.json): Complete shaded JSON API based on Jakarta JSON and Apache Johnzon
  • Exception Layer: Comprehensive typed exception hierarchy for different error conditions
  • Logging Layer (org.apache.activemq.artemis.logs): Internationalized logging with audit capabilities

Key design principles:

  • Performance Focus: Extensive use of object pooling and optimized data structures like SimpleString
  • Type Safety: Strong typing with comprehensive exception hierarchy
  • Fluent APIs: Builder and chain patterns for configuration classes
  • Zero Dependencies: Self-contained with shaded JSON dependencies

Capabilities

Core API and Configuration

Central configuration classes and core data types for queue management, message routing, and buffer operations.

// Queue configuration with fluent API
QueueConfiguration config = QueueConfiguration.of("queueName")
    .setAddress(SimpleString.of("address"))
    .setRoutingType(RoutingType.ANYCAST);

// High-performance string handling
SimpleString str = SimpleString.of("text");
byte[] data = str.getData();

// Buffer operations
ActiveMQBuffer buffer = /* ... */;
buffer.writeSimpleString(str);

Core API and Configuration

Collections Utilities

Specialized high-performance collection implementations for concurrent operations, primitive types, and type-safe properties.

// Concurrent collections with no boxing overhead
ConcurrentLongHashMap<Message> messages = new ConcurrentLongHashMap<>(1000);
messages.put(messageId, message);

// Type-safe properties with JMS-compliant conversions
TypedProperties props = new TypedProperties();
props.putIntProperty(SimpleString.of("priority"), 5);

Collections Utilities

Actor Framework

Asynchronous message processing framework with guaranteed ordering, backpressure management, and sophisticated state control.

// Create actor for ordered message processing
Actor<String> actor = new Actor<>(executor, message -> processMessage(message));
actor.act("message");

// Threshold-based flow control
ThresholdActor<Buffer> bufferActor = new ThresholdActor<>(
    executor, this::processBuffer, maxSize, Buffer::size, 
    this::applyBackpressure, this::releaseBackpressure);

Actor Framework

Exception Handling

Comprehensive exception hierarchy with 40+ specific exception types for different error conditions in ActiveMQ Artemis.

try {
    // ActiveMQ operations
} catch (ActiveMQException e) {
    ActiveMQExceptionType type = e.getType();
    // Handle based on specific exception type
}

Exception Handling

Utility Classes

Threading, pooling, validation, environment access, and general-purpose utilities for Artemis components.

// Thread factory with proper naming
ActiveMQThreadFactory factory = new ActiveMQThreadFactory("MyGroup", true, classLoader);
Thread thread = factory.newThread(runnable);

// Byte utilities
byte[] bytes = ByteUtil.hexStringToByteArray("48656c6c6f");
String hex = ByteUtil.bytesToHex(bytes);

Utility Classes

JSON Processing

Complete JSON API implementation with object/array builders, providing Jakarta JSON compatibility through shaded dependencies.

// Create JSON objects
JsonObject obj = JsonLoader.createObjectBuilder()
    .add("name", "value")
    .add("number", 42)
    .build();

// Parse JSON
JsonObject parsed = JsonLoader.readObject(new StringReader(jsonString));
String value = parsed.getString("name");

JSON Processing

Logging and Audit

Internationalized logging framework with audit capabilities for system events and operations.

// Access logging interfaces
ActiveMQUtilLogger logger = /* ... */;
AuditLogger.log(event, details);

Logging and Audit

Types

// Core routing types
enum RoutingType {
    MULTICAST(0),
    ANYCAST(1);
    
    byte getType();
    static RoutingType getType(byte type);
}

// Generic pair utility
class Pair<A, B> implements Serializable {
    public A a;
    public B b;
    
    public Pair(A a, B b);
}

// Object + long combination
class ObjLongPair<A> {
    public A obj;
    public long longValue;
    
    public ObjLongPair(A obj, long longValue);
}