Apache Artemis Documentation

repository·main·Indexed 21 days ago

https://github.com/apache/artemis

A high-performance, multi-protocol message broker supporting AMQP 1.0, MQTT 3.1.1, MQTT 5, and STOMP. This documentation covers broker configuration, OCI image builds and deployment via Podman/Docker, and the use of the Artemis CLI for managing addresses, queues, users, and activation groups, as well as producing and consuming messages.

Tokens
165.6K
Snippets
422
Records
678
Agent score
77%

What's inside Apache Artemis

  1. Overview of Apache Artemis messaging capabilities

    main

    Apache Artemis is a multi-protocol message broker designed to support various industry-standard protocols. This allows for cross-platform connectivity using clients written in languages such as Java, JavaScript, C, C++, Python, and .NET.

    Supported protocols include:

    • AMQP 1.0
    • MQTT 3.1.1
    • MQTT 5
    • STOMP
  2. Overview of Artemis Performance Tools

    main

    Apache Artemis provides command-line performance test tools based on the JMS 2 API to stress test broker instances. These tools allow you to simulate various load scenarios, such as all-out throughput or specific target rates.

    The available tools are:

    • producer: Generates load using BytesMessage of a configured size. Can generate all-out throughput or target-rate load.
    • consumer: Uses a MessageListener to consume messages sent by a producer.
    • client: A combined tool that packs both producer and consumer functionality into a single command. This is the most common tool used for testing.

    Using separate producer and consumer tools is useful for advanced scenarios like delaying consumer starts to test broker paging or running producers and consumers on different machines.

  3. Overview of Artemis Data Tools

    main

    The artemis data CLI command provides a suite of tools for performing data maintenance, recovery, and migration on an Artemis broker instance. These tools allow you to interact with the message journal, export/import data, and perform recovery operations.

    Available sub-commands:

    • print: Reports on journal records (use on non-running servers).
    • exp: Exports message data to a universal XML format.
    • imp: Imports message data from an XML export into a running broker.
    • encode: Converts journal files into an internal encoded string format.
    • decode: Converts an internal encoded format back into journal files.
    • compact: Compacts the journal of a non-running server.
    • recover: Recovers (undeletes) messages from an existing journal into a new one.
  4. Access the Apache Artemis Management API

    main

    Apache Artemis provides an extensive management API to modify server configuration, create/inspect resources (addresses, queues), and interact with messages. You can access this API through several interfaces, all of which support the same functionality:

    • JMX: The standard way to manage Java applications.
    • Jolokia: Exposes the JMX API via an HTTP interface.
    • Core Client: Sends management operations using Core Client messages.
    • JMS Client: Sends management operations using JMS Client messages.
    • Web Console: A graphical web application.
    • Command Line: A management utility for administrators.
  5. Use the Apache Artemis CLI

    main

    The Apache Artemis Command Line Interface (CLI) allows you to manage broker instances, users, queues, and addresses. It is designed for human interaction and simple use cases. For automated processes or scripting, use the comprehensive management API which returns JSON output.

    You can interact with the CLI in two ways:

    1. Traditional CLI commands: Execute individual commands from your terminal (e.g., ./artemis [COMMAND] [PARAMETERS]).
    2. Custom Shell: Enter an interactive session using ./artemis or ./artemis shell. The shell reuses connection information (broker URI, username, password) across commands within the same session.
    # Traditional command usage
    ./artemis help
    
    # Interactive shell usage
    ./artemis shell
  6. What is Federation in Apache Artemis

    main

    Federation allows for the transmission of messages between brokers without the requirement of a cluster. This makes it ideal for scenarios involving Wide Area Networks (WAN), cross-region communication, or connecting brokers in different administrative domains (e.g., different configurations, users, or versions).

    There are two primary types of federation:

    1. Address Federation: Similar to multicast. Every message sent to an address on the source broker is delivered to all queues on that broker, as well as to the connected federated broker and all its attached queues. This is only supported with multicast addresses.
    2. Queue Federation: Allows multiple receivers on different machines to act as a single logical queue. This is useful for load balancing across WAN or cross-region boundaries where clustering is not feasible.
  7. What is Queue Federation and when to use it

    main

    Queue Federation allows you to balance the load of a single logical queue across multiple remote brokers. A federated queue links to one or more "upstream queues" on remote brokers to satisfy local consumer demand.

    Key Use Cases:

    • Higher Capacity: Distribute a single logical queue across many brokers to increase total capacity.
    • Multi-region/Venue Support: Keep producers and consumers local to their respective regions while using federation to move messages over the WAN.
    • DMZ to Secure LAN Communication: Allow producers in a DMZ to publish to a DMZ broker, which then federates messages to a broker in the secure enterprise LAN.
    • Cluster Migration: Move consumers and publishers between clusters without duplicating messages. Using a priority-adjustment of 0 or a positive value can actively drive message flow to the new cluster during migration.

    Important Note: The federation name must be globally unique.

  8. What is AMQP Queue Federation

    main

    Queue federation is a mechanism for load balancing message queues across multiple Apache Artemis broker instances. It works by creating federation consumers that pull messages from a matching queue on a remote peer when there is no local consumer available to handle the messages on the local queue.

    Key behaviors:

    • Competing Consumers: The federation consumer acts as an additional consumer on the remote queue, competing with local consumers on that remote queue for messages.
    • Directionality: Federation can be configured as single-direction (messages flow from one broker to another) or bi-directional (messages can migrate back and forth between brokers based on capacity and consumer availability).
    • Capacity Management: You can configure federation to only pull messages from a remote queue if the local broker has the capacity to handle them, preventing local backlogs from growing unnecessarily.
  9. What is Address Federation

    main

    Address federation allows multiple Apache Artemis brokers to share messages across addresses. It functions similarly to multicast over connected brokers: every message sent to an address on Broker-A is delivered to all queues on that broker, and also to Broker-B and all its attached queues.

    Key characteristics:

    • Dynamic Linking: It links to addresses in upstream or downstream brokers.
    • Automatic Queue Creation: The downstream broker automatically creates a durable queue on the remote (upstream) address to consume and copy messages locally.
    • Low Configuration Overhead: Upstream brokers do not need reconfiguration to accept new downstream federations; you only need to ensure the downstream broker has the necessary permissions for the address.
  10. Configure Federation for Load Balancing or Multicast

    main

    Federation allows brokers to share demand for addresses or queues.

    • Address Federation (Multicast): Messages sent to an address on one broker are delivered to all matching addresses and queues across all federated brokers.
    • Queue Federation (Load Balancing): Messages sent to a queue on one broker are sent to the matching queue on another broker if no local consumer is available.

    Configuration: Add a <federation> element within an <amqp-connection>. It consists of policies defining how to include or exclude addresses/queues.

    Policy Types:

    • local-address-policy / local-queue-policy: Governs local demand.
    • remote-address-policy / remote-queue-policy: Governs remote demand.
    <broker-connections>
      <amqp-connection uri="tcp://HOST:PORT" name="federation-example">
        <federation>
           <local-address-policy name="example-local-address-policy">
             <include address-match="local-address.#" />
             <exclude address-match="local-address.excluded" />
           </local-address-policy>
           <!-- other policies -->
        </federation>
      </amqp-connection>
    </broker-connections>
  11. Map STOMP destinations to Addresses and Queues

    main

    STOMP clients use string-based destinations. Artemis maps these to internal addresses and queues based on routing semantics.

    Client-Side Configuration

    When sending a SEND frame, use the destination-type header:

    • ANYCAST: Maps the destination to an address of the same name and a queue of the same name.
    • MULTICAST: Maps the destination to an address of the same name (for pub/sub).

    When subscribing with a SUBSCRIBE frame, use the subscription-type header to specify similar semantics.

    Broker-Side Configuration

    You can control routing via:

    1. Prefixes: Set anycastPrefix or multicastPrefix on the acceptor. For example, if anycastPrefix=queue/, a destination queue/foo is treated as anycast, and the prefix is stripped before creating address foo and queue foo.
    2. Address Settings: Use <address-setting> in broker.xml with a match pattern to define default-address-routing-type and default-queue-routing-type.
    <address-settings>
       <address-setting match="queue/#">
          <default-address-routing-type>ANYCAST</default-address-routing-type>
          <default-queue-routing-type>ANYCAST</default-queue-routing-type>
       </address-setting>
       <address-setting match="topic/#">
          <default-address-routing-type>MULTICAST</default-address-routing-type>
          <default-queue-routing-type>MULTICAST</default-queue-routing-type>
       </address-setting>
    </address-settings>
    <wildcard-addresses>
       <delimiter>/</delimiter>
    </wildcard-addresses>