---
title: How to Deploy ActiveMQ Artemis as a Self-Hosted Azure Service Bus Alternative
url: https://docs.vultr.com/how-to-deploy-activemq-artemis-as-a-self-hosted-azure-service-bus-alternative
description: Deploy ActiveMQ Artemis on Vultr as an Azure Service Bus alternative with high availability, dead-letter queues, AMQP clients, security roles, and migration.
publish_date: 2026-11-21T01:55:47.230186Z
last_updated: 2026-11-25T19:35:07.107664Z
author: Shivang Shandilya
header_image: https://docs.vultr.com/public/doc-assets/2678/6d2c8b6a-fa91-461b-944d-07f84da3f698.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

[Azure Service Bus](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview) is Microsoft's fully managed enterprise message broker that provides queues, publish/subscribe topics, sessions, and dead-letter handling within the Azure ecosystem. It removes the operational burden of running a broker, but it ties workloads to Azure-specific SDKs, namespace-based pricing tiers, and Microsoft's connectivity model.

[Apache Artemis](https://artemis.apache.org/components/artemis/) is an open-source, multi-protocol message broker that provides queueing, publish/subscribe, and dead-letter capabilities as a self-hosted deployment on any infrastructure. It supports Advanced Message Queuing Protocol (AMQP) 1.0 natively (the same protocol Service Bus exposes), along with MQTT, Simple Text Oriented Messaging Protocol (STOMP), OpenWire, and its own Core protocol, and it stores all messages and configuration within your own environment.

This article explains how to deploy Apache Artemis with Docker or as a standalone Linux service, configure a primary and backup broker pair for high availability (HA), enable multiple messaging protocols, secure the broker, set up dead-letter queues and message routing, monitor the broker, and migrate application code from Azure Service Bus.

## Understanding Apache Artemis Architecture

Apache Artemis covers most core Azure Service Bus concepts through an open, standards-based broker. In Artemis, clients send messages to an *address*, and the address routes each message to one or more *queues* that hold messages for consumers. An address with the ANYCAST routing type routes each message to only one of its queues for point-to-point delivery, and an address with the MULTICAST routing type routes a copy of each message to every queue bound to it for publish/subscribe delivery. The following table maps each Service Bus construct to its Artemis counterpart and notes where the migration involves a different mechanism rather than a drop-in equivalent.

| Azure Service Bus | Apache Artemis | Description |
|--------------------|-------------------|--------------|
| Namespace | Broker instance | Top-level container for queues, topics, and connection endpoints. |
| Queues | ANYCAST queues | Point-to-point delivery to a single consumer. |
| Topics and Subscriptions | Addresses with MULTICAST queues | Publish/subscribe delivery to multiple independent consumers. |
| Sessions | Message grouping (partial) | Ordered delivery of related messages to one consumer. Artemis has no session state or session lock. |
| Duplicate detection window | `_AMQ_DUPL_ID` property and ID cache | Suppresses a message sent more than once. Artemis remembers a fixed number of IDs rather than a time window. |
| Automatic dead-letter sub-queue | `dead-letter-address` | Destination for messages that exceed delivery attempts or that a consumer rejects. |
| Shared Access Signatures (SAS) / Microsoft Entra ID | Java Authentication and Authorization Service (JAAS) login modules (users/roles properties files, LDAP) | Client authentication and authorization model. |
| AMQP 1.0 | AMQP 1.0, Core, OpenWire, STOMP, MQTT | Wire protocols clients use to connect to the service. |
| Availability zones within a region | Primary/backup replication or shared-store HA | Failover between broker nodes in the same location. |
| Premium tier geo-disaster recovery and geo-replication | AMQP broker connection mirroring | Replication of messages to a broker in another location. |
| Namespace tiers and messaging units | Self-hosted compute and broker clustering | How the service scales and how you pay for it. |

## Prerequisites

Before you begin, you need to:

* Have access to a [Linux-based server](https://www.vultr.com/features/operating-systems/) (with at least 2 CPU cores and 4 GB of RAM) as a [non-root user with sudo privileges](https://docs.vultr.com/how-to-create-a-sudo-user-in-linux).
* **(Optional)** Provision a second server if you intend to configure high availability with a primary and backup broker pair.
* [Install Docker and Docker Compose](https://docs.vultr.com/how-to-install-docker-on-ubuntu-24-04#install-docker) for the containerized deployment.
* [Install OpenJDK 17 or later](https://docs.vultr.com/how-to-install-apache-tomcat-on-ubuntu-24-04#install-java-openjdk) for the standalone deployment.

## Deploy Apache Artemis

Artemis runs either as a container managed by Docker Compose or as a standalone service managed by systemd. Choose one method. The Docker method places a reverse proxy in front of the web console and obtains certificates automatically. The standalone method gives you direct control over the broker files and uses Nginx with Certbot for HTTPS. Later sections provide commands for both methods, so use the command that matches your deployment.

### Deploy with Docker Compose

Docker Compose runs Artemis and its reverse proxy as containers defined in a single file. This setup includes Traefik as a reverse proxy to serve the web console over HTTPS with Let's Encrypt certificates.

1. Create a DNS `A` record that points your domain, such as `artemis.example.com`, to the public IP address of your server. For more information, see [how to manage DNS records](https://docs.vultr.com/products/network/dns/management/manage-records).

1. Allow HTTP and HTTPS traffic through the firewall. Let's Encrypt uses port `80` to validate the domain, and browsers reach the web console on port `443`.

    ```console
    $ sudo ufw allow 80,443/tcp
    ```

1. Create the project directory with subdirectories for message data and certificates.

    ```console
    $ mkdir -p ~/artemis/{data,letsencrypt}
    ```

    * `data`: Persists the broker instance, including configuration and message storage.
    * `letsencrypt`: Stores Transport Layer Security (TLS) certificates.

1. Navigate to the project directory.

    ```console
    $ cd ~/artemis
    ```

1. Create a `.env` file.

    ```console
    $ nano .env
    ```

1. Add the following environment configuration. Replace:

    * `artemis.example.com` with your configured domain.
    * `admin@example.com` with your email address.
    * `ADMIN_USER` with your preferred administrator username.
    * `ADMIN_PASSWORD` with a strong password.

    ```ini
    ARTEMIS_DOMAIN=artemis.example.com
    ACME_EMAIL=admin@example.com
    ARTEMIS_USER=ADMIN_USER
    ARTEMIS_PASSWORD=ADMIN_PASSWORD
    ```

    Save and close the file.

1. Create the certificate storage file.

    ```console
    $ touch letsencrypt/acme.json
    ```

1. Restrict the file to owner-only access. Traefik refuses to use a certificate storage file that other users can read.

    ```console
    $ chmod 600 letsencrypt/acme.json
    ```

1. Assign ownership of the data directory to the user that the Artemis container runs as. The official image runs the broker as the `artemis` user with UID and GID `1001`.

    ```console
    $ sudo chown -R 1001:1001 data
    ```

1. Create the Docker Compose configuration file.

    ```console
    $ nano docker-compose.yml
    ```

1. Add the following configuration:

    ```yaml
    services:
      traefik:
        image: traefik:v3.7.11
        container_name: traefik
        command:
          - "--providers.docker=true"
          - "--providers.docker.exposedbydefault=false"
          - "--entrypoints.web.address=:80"
          - "--entrypoints.websecure.address=:443"
          - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
          - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
          - "--certificatesresolvers.le.acme.email=${ACME_EMAIL}"
          - "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
          - "--certificatesresolvers.le.acme.httpchallenge=true"
          - "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - "/var/run/docker.sock:/var/run/docker.sock:ro"
          - "./letsencrypt:/letsencrypt"
        restart: unless-stopped

      artemis:
        image: apache/artemis:2.57.0
        container_name: artemis
        environment:
          - ARTEMIS_USER=${ARTEMIS_USER}
          - ARTEMIS_PASSWORD=${ARTEMIS_PASSWORD}
          - ANONYMOUS_LOGIN=false
          - EXTRA_ARGS=--http-host 0.0.0.0 --relax-jolokia
        ports:
          - "61616:61616"
          - "5672:5672"
          - "61613:61613"
          - "1883:1883"
        volumes:
          - ./data:/var/lib/artemis-instance
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.artemis.rule=Host(`${ARTEMIS_DOMAIN}`)"
          - "traefik.http.routers.artemis.entrypoints=websecure"
          - "traefik.http.routers.artemis.tls.certresolver=le"
          - "traefik.http.services.artemis.loadbalancer.server.port=8161"
        restart: unless-stopped
    ```

    Save and close the file.

    The configuration exposes:

    * `Port 80, 443`: Traefik HTTP/HTTPS entry points for the web console.
    * `Port 61616`: Core and OpenWire connections, and broker-to-broker traffic for high availability.
    * `Port 5672`: AMQP 1.0 protocol, used by applications migrating from Azure Service Bus.
    * `Port 61613`: STOMP protocol for text-based messaging.
    * `Port 1883`: MQTT protocol for Internet of Things (IoT) applications.

    Docker does not publish the web console port `8161` on the host. Traefik reaches it over the internal Docker network. The `EXTRA_ARGS` environment variable binds the embedded web server to all container interfaces (`--http-host 0.0.0.0`) so that Traefik can reach it, and disables strict origin checking for Jolokia (`--relax-jolokia`). Jolokia is a bridge that converts HTTP requests into Java Management Extensions (JMX) operations, and the web console uses it to read and manage the broker.

    > [!WARNING]
    > Docker publishes container ports with its own firewall rules, and UFW does not filter them. The four broker ports are reachable from the internet and are protected only by broker authentication. Remove the mapping for any protocol you do not use, bind a port to the loopback interface (for example, `"127.0.0.1:61613:61613"`) if only local clients need it, or restrict source addresses with a network-level firewall in front of the server.

1. Start the stack in detached mode.

    ```console
    $ docker compose up -d
    ```

1. Verify the containers are running.

    ```console
    $ docker compose ps
    ```

    The output lists the `traefik` and `artemis` containers with a status of `Up`.

1. Check the Artemis startup logs for any errors.

    ```console
    $ docker compose logs artemis
    ```

    The output shows the broker starting each acceptor, the network listener that accepts client connections on a port for one or more protocols, and ends with a message that the server is now active.

1. Confirm from a different machine that the web console port is not reachable directly. Replace `SERVER_IP` with the public IP address of your server.

    ```console
    $ nc -zv SERVER_IP 8161
    ```

    The connection fails or times out, which confirms that the console is reachable only through Traefik.

1. Configure Jolokia to accept requests from the HTTPS reverse proxy. When Traefik terminates TLS, the browser sends an `Origin` header with the HTTPS scheme, but Artemis receives the request over plain HTTP internally. By default, Jolokia treats this scheme mismatch as a potential security issue and rejects the request, which causes the web console dashboard to appear blank after login. Open the Jolokia access configuration file.

    ```console
    $ sudo nano ~/artemis/data/etc/jolokia-access.xml
    ```

1. Locate the `<cors>` section. The default section looks like this:

    ```xml
    <cors>
        <allow-origin>*://0.0.0.0*</allow-origin>
        <!--ignore-scheme/-->
    </cors>
    ```

    Make two edits:

    * Replace `*://0.0.0.0*` with `*://artemis.example.com*` in the `<allow-origin>` line, using your domain.
    * Change `<!--ignore-scheme/-->` to `<ignore-scheme/>` by removing the leading `<!--` and trailing `-->` so it becomes an active XML element, not a comment.

    The `<cors>` section must look like this when you are done:

    ```xml
    <cors>
        <allow-origin>*://artemis.example.com*</allow-origin>
        <ignore-scheme/>
    </cors>
    ```

    Save and close the file.

    * `allow-origin`: Accepts browser requests only from your console domain.
    * `ignore-scheme`: Stops Jolokia from rejecting requests where the browser used HTTPS but the internal proxy connection is HTTP. Without it, the dashboard loads but stays blank.

1. Restart the Artemis container to apply the Jolokia configuration.

    ```console
    $ docker compose restart artemis
    ```

    > [!NOTE]
    > For more information on managing Docker Compose stacks, see the [How to Use Docker Compose](https://docs.vultr.com/how-to-use-docker-compose) article.

### Deploy on a Standalone Server

A standalone installation provides direct control over the broker configuration and integrates with systemd for automatic startup and process management.

1. Download the Artemis 2.57.0 binary distribution from the Apache archive, which keeps every released version available at a stable URL.

    ```console
    $ sudo curl -fsSL https://archive.apache.org/dist/artemis/artemis/2.57.0/apache-artemis-2.57.0-bin.tar.gz -o /opt/artemis.tar.gz
    ```

    > [!NOTE]
    > Check the [official Artemis download page](https://artemis.apache.org/components/artemis/download/) for newer versions, and substitute the version number in the URL and folder names below if you use a different release.

1. Extract the archive into `/opt`, the conventional location for third-party software that the package manager does not manage.

    ```console
    $ sudo tar -xzf /opt/artemis.tar.gz -C /opt
    ```

1. Rename the extracted directory to `artemis` for shorter, stable paths across upgrades.

    ```console
    $ sudo mv /opt/apache-artemis-2.57.0 /opt/artemis
    ```

1. Create a dedicated system user for the broker.

    ```console
    $ sudo useradd -r -s /sbin/nologin artemis
    ```

1. Create a broker instance. Replace:

    * `ADMIN_USER` with your preferred administrator username.
    * `ADMIN_PASSWORD` with a strong password.

    ```console
    $ sudo /opt/artemis/bin/artemis create /var/lib/artemis \
        --user ADMIN_USER \
        --password ADMIN_PASSWORD \
        --host 0.0.0.0 \
        --require-login
    ```

    In the above command:

    * `--host 0.0.0.0`: Binds the messaging acceptors to all interfaces so that remote clients can connect. The web console stays bound to `localhost`.
    * `--require-login`: Disables anonymous access, so all clients must authenticate.

1. Set ownership of the broker directory.

    ```console
    $ sudo chown -R artemis:artemis /var/lib/artemis
    ```

1. Create the systemd service file.

    ```console
    $ sudo nano /etc/systemd/system/artemis.service
    ```

1. Add the following configuration:

    ```ini
    [Unit]
    Description=Apache Artemis
    After=network.target

    [Service]
    Type=forking
    User=artemis
    Group=artemis
    PIDFile=/var/lib/artemis/data/artemis.pid
    ExecStart=/var/lib/artemis/bin/artemis-service start
    ExecStop=/var/lib/artemis/bin/artemis-service stop
    Restart=on-failure
    RestartSec=10

    [Install]
    WantedBy=multi-user.target
    ```

    Save and close the file.

    * `Type=forking`: The `artemis-service` script starts the broker in the background and exits.
    * `PIDFile`: Points systemd to the process ID file that `artemis-service` writes, so systemd tracks the broker process instead of the exited script.
    * `Restart=on-failure`: Restarts the broker 10 seconds after an unexpected exit.

1. Reload the systemd daemon.

    ```console
    $ sudo systemctl daemon-reload
    ```

1. Enable the service to start on boot.

    ```console
    $ sudo systemctl enable artemis
    ```

1. Start the Artemis service.

    ```console
    $ sudo systemctl start artemis
    ```

1. Verify the service is running.

    ```console
    $ sudo systemctl status artemis
    ```

    The output shows `Active: active (running)`.

1. Allow the broker protocol ports through the firewall so that remote clients and a backup broker can connect.

    ```console
    $ sudo ufw allow 5672,61616,61613,1883/tcp
    ```

    * `5672`: AMQP 1.0.
    * `61616`: Core and OpenWire, and broker-to-broker traffic for high availability.
    * `61613`: STOMP.
    * `1883`: MQTT.

    Omit any protocol port you do not use. To limit a port to known clients, use a source-restricted rule such as `sudo ufw allow from 192.0.2.0/24 to any port 5672 proto tcp`.

### Secure the Standalone Web Console with HTTPS

The standalone broker serves its web console over plain HTTP on the loopback interface. Use Nginx as a reverse proxy with a Let's Encrypt certificate from Certbot to serve the console over HTTPS.

1. Create a DNS `A` record that points your domain, such as `artemis.example.com`, to the public IP address of your server. For more information, see [how to manage DNS records](https://docs.vultr.com/products/network/dns/management/manage-records).

1. Allow HTTP and HTTPS traffic through the firewall. Let's Encrypt uses port `80` to validate the domain, and browsers reach the web console on port `443`.

    ```console
    $ sudo ufw allow 80,443/tcp
    ```

1. Update the package index.

    ```console
    $ sudo apt update
    ```

1. Install Nginx, Certbot, and the Nginx plugin for Certbot.

    ```console
    $ sudo apt install -y nginx certbot python3-certbot-nginx
    ```

1. Obtain a Let's Encrypt certificate for your domain. Replace:

    * `artemis.example.com` with your domain.
    * `admin@example.com` with your email address.

    ```console
    $ sudo certbot certonly --nginx -d artemis.example.com --email admin@example.com --agree-tos --non-interactive
    ```

1. Create an Nginx configuration file for the Artemis console.

    ```console
    $ sudo nano /etc/nginx/sites-available/artemis
    ```

1. Add the following configuration, replacing `artemis.example.com` with your domain:

    ```ini
    server {
        listen 80;
        server_name artemis.example.com;
        return 301 https://$host$request_uri;
    }

    server {
        listen 443 ssl;
        server_name artemis.example.com;

        ssl_certificate /etc/letsencrypt/live/artemis.example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/artemis.example.com/privkey.pem;
        include /etc/letsencrypt/options-ssl-nginx.conf;
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

        location / {
            proxy_pass http://localhost:8161;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
    ```

    Save and close the file.

    * The first `server` block redirects all HTTP requests to HTTPS.
    * The second `server` block terminates TLS with the Let's Encrypt certificate and forwards requests to the web console on `localhost:8161`.

1. Enable the site by linking it into `sites-enabled`.

    ```console
    $ sudo ln -s /etc/nginx/sites-available/artemis /etc/nginx/sites-enabled/
    ```

1. Test the Nginx configuration for syntax errors.

    ```console
    $ sudo nginx -t
    ```

    The output confirms that the configuration file syntax is ok and the test is successful.

1. Reload Nginx to apply the configuration.

    ```console
    $ sudo systemctl reload nginx
    ```

1. Confirm that Nginx is active and running.

    ```console
    $ sudo systemctl status nginx
    ```

    The output shows `Active: active (running)`.

1. Configure Jolokia to accept requests from the HTTPS reverse proxy. When Nginx terminates TLS, the browser sends an `Origin` header with the HTTPS scheme, but Artemis receives the request over plain HTTP internally. By default, Jolokia treats this scheme mismatch as a potential security issue and rejects the request, which causes the web console dashboard to appear blank after login. Open the Jolokia access configuration file.

    ```console
    $ sudo nano /var/lib/artemis/etc/jolokia-access.xml
    ```

1. Locate the `<cors>` section. The default section looks like this:

    ```xml
    <cors>
        <allow-origin>*://localhost*</allow-origin>
        <!--ignore-scheme/-->
        <strict-checking/>
    </cors>
    ```

    Make two edits:

    * Replace `*://localhost*` with `*://artemis.example.com*` in the `<allow-origin>` line, using your domain.
    * Change `<!--ignore-scheme/-->` to `<ignore-scheme/>` by removing the leading `<!--` and trailing `-->` so it becomes an active XML element, not a comment.

    The `<cors>` section must look like this when you are done:

    ```xml
    <cors>
        <allow-origin>*://artemis.example.com*</allow-origin>
        <ignore-scheme/>
        <strict-checking/>
    </cors>
    ```

    Save and close the file.

    * `allow-origin`: Accepts browser requests only from your console domain.
    * `ignore-scheme`: Stops Jolokia from rejecting requests where the browser used HTTPS but the internal proxy connection is HTTP. Without it, the dashboard loads but stays blank.

1. Restart Artemis to apply the changes.

    ```console
    $ sudo systemctl restart artemis
    ```

## Access the Artemis Web Console

The web console is a Hawtio-based browser interface for monitoring broker health, managing queues, browsing messages, and viewing metrics.

1. Open a web browser and navigate to the Artemis console at `https://artemis.example.com/console`, replacing `artemis.example.com` with your configured domain.

1. Log in with the administrator credentials you configured during deployment. The dashboard displays the **Status** tab by default, showing broker information including the version, uptime, and HA policy, along with an address memory usage chart.

1. Select the **Addresses** tab to view existing addresses and create new ones. Artemis pre-creates default addresses, including `DLQ` and `ExpiryQueue`.

1. Click **Create Address** to add a new address. In the **Create Address** dialog:

    * Enter an address name in the **Address Name** field (for example, `orders`).
    * Select the **Routing Type** (**Anycast** for point-to-point or **Multicast** for publish/subscribe).
    * Click **Create Address**.

1. Select the **Queues** tab to view all queues bound to their respective addresses.

1. Select the **Broker Diagram** tab to view the visual topology of the broker including all addresses and queues.

## Configure Message Persistence

Artemis persists messages in the journal, a set of append-only files on disk. Both Docker and standalone installations pre-configure working defaults. Modify these values only if you need to tune performance or durability for your workload.

1. Open the broker configuration file.

    * Docker:

        ```console
        $ sudo nano ~/artemis/data/etc/broker.xml
        ```

    * Standalone:

        ```console
        $ sudo nano /var/lib/artemis/etc/broker.xml
        ```

1. Locate the journal settings in the `<core>` section. The instance creation step selects the journal type based on what the host supports:

    * Docker (the official image includes `libaio`, so it uses Linux asynchronous I/O):

        ```xml
        <journal-type>ASYNCIO</journal-type>
        <journal-directory>data/journal</journal-directory>
        <journal-min-files>2</journal-min-files>
        <journal-pool-files>10</journal-pool-files>
        <journal-file-size>10M</journal-file-size>
        ```

    * Standalone (falls back to Java NIO when `libaio` is not available on the host):

        ```xml
        <journal-type>NIO</journal-type>
        <journal-datasync>true</journal-datasync>
        <journal-min-files>2</journal-min-files>
        <journal-pool-files>10</journal-pool-files>
        <journal-device-block-size>4096</journal-device-block-size>
        <journal-file-size>10M</journal-file-size>
        <paging-directory>data/paging</paging-directory>
        <bindings-directory>data/bindings</bindings-directory>
        <journal-directory>data/journal</journal-directory>
        <large-messages-directory>data/large-messages</large-messages-directory>
        ```

    Adjust these values if needed, then save and close the file.

    Key settings:

    * `journal-type`: `ASYNCIO` uses Linux native asynchronous I/O for the best performance and requires the `libaio` library on the host. `NIO` uses standard Java I/O and works on any platform. Do not set `ASYNCIO` on a host without `libaio`.
    * `journal-datasync`: When `true`, calls `fdatasync` on journal writes so that data survives a power failure.
    * `journal-min-files`: Number of journal files the broker pre-creates at startup.
    * `journal-pool-files`: Number of journal files the broker keeps for reuse when it reclaims files, so that it does not create new files during writes.
    * `large-messages-directory`: Stores large messages, which the broker persists outside the journal when they exceed the `min-large-message-size` threshold (default 100 KiB).

1. Restart the broker to apply changes.

    * Docker:

        ```console
        $ docker compose restart artemis
        ```

    * Standalone:

        ```console
        $ sudo systemctl restart artemis
        ```

## Test AMQP Protocol Support

AMQP 1.0 is the protocol that Azure Service Bus applications use, so it is the most important protocol to confirm. Both Docker and standalone installations pre-configure AMQP, STOMP, MQTT, and OpenWire acceptors by default. Create a durable point-to-point queue, then send and receive a message with a Python AMQP client.

1. Create a durable ANYCAST queue named `test-queue`. Pre-creating the queue guarantees that the broker stores the message even when no consumer is connected.

    * Docker:

        ```console
        $ docker exec artemis /var/lib/artemis-instance/bin/artemis queue create \
            --name test-queue --address test-queue --anycast --durable \
            --preserve-on-no-consumers --auto-create-address --silent \
            --user ADMIN_USER --password ADMIN_PASSWORD --url tcp://localhost:61616
        ```

    * Standalone:

        ```console
        $ sudo -u artemis /var/lib/artemis/bin/artemis queue create \
            --name test-queue --address test-queue --anycast --durable \
            --preserve-on-no-consumers --auto-create-address --silent \
            --user ADMIN_USER --password ADMIN_PASSWORD --url tcp://localhost:61616
        ```

    The output confirms that the queue was created.

1. Install the Python venv package.

    ```console
    $ sudo apt install python3-venv -y
    ```

1. Create a Python virtual environment.

    ```console
    $ python3 -m venv ~/amqp-test
    ```

1. Activate the virtual environment.

    ```console
    $ source ~/amqp-test/bin/activate
    ```

1. Install the Apache Qpid Proton AMQP client library.

    ```console
    $ pip install python-qpid-proton
    ```

1. Create a script that sends one message.

    ```console
    $ nano ~/amqp-test/amqp_send.py
    ```

1. Add the following code. Replace `SERVER_IP` with the IP address of your broker, and `ADMIN_USER` and `ADMIN_PASSWORD` with your administrator credentials.

    ```python
    import sys
    from proton import Message
    from proton.utils import BlockingConnection

    BROKER_URL = "amqp://SERVER_IP:5672"
    USER = "ADMIN_USER"
    PASSWORD = "ADMIN_PASSWORD"
    ADDRESS = sys.argv[1] if len(sys.argv) > 1 else "test-queue"

    conn = BlockingConnection(BROKER_URL, user=USER, password=PASSWORD)
    sender = conn.create_sender(ADDRESS)
    sender.send(Message(body="Hello from Artemis"))
    print(f"Sent message to {ADDRESS}")
    conn.close()
    ```

    Save and close the file.

    * **Connect:** `BlockingConnection` opens an AMQP connection and authenticates with the Simple Authentication and Security Layer (SASL) PLAIN mechanism.
    * **Send:** `sender.send` waits until the broker confirms that it stored the message.
    * **Address:** The script sends to `test-queue` unless you pass another address as the first argument.

1. Create a script that receives one message.

    ```console
    $ nano ~/amqp-test/amqp_receive.py
    ```

1. Add the following code. Replace `SERVER_IP`, `ADMIN_USER`, and `ADMIN_PASSWORD` with the same values you used in the send script.

    ```python
    import sys
    from proton.utils import BlockingConnection

    BROKER_URL = "amqp://SERVER_IP:5672"
    USER = "ADMIN_USER"
    PASSWORD = "ADMIN_PASSWORD"
    ADDRESS = sys.argv[1] if len(sys.argv) > 1 else "test-queue"
    ACTION = sys.argv[2] if len(sys.argv) > 2 else "accept"

    conn = BlockingConnection(BROKER_URL, user=USER, password=PASSWORD)
    receiver = conn.create_receiver(ADDRESS)
    message = receiver.receive(timeout=10)
    print(f"Received: {message.body}")
    if ACTION == "reject":
        receiver.reject()
    else:
        receiver.accept()
    conn.close()
    ```

    Save and close the file.

    * **Receive:** `receiver.receive(timeout=10)` waits up to 10 seconds for a message and raises a timeout error if none arrives, so the script never hangs.
    * **Settle:** `accept()` removes the message from the queue. Passing `reject` as the second argument rejects the message instead, which the dead-letter test uses later.

1. Send a test message.

    ```console
    $ python3 ~/amqp-test/amqp_send.py
    ```

    The output confirms that the message was sent to `test-queue`.

1. Receive the test message.

    ```console
    $ python3 ~/amqp-test/amqp_receive.py
    ```

    The output displays `Received: Hello from Artemis`.

## Configure High Availability with a Primary and Backup Broker

Artemis provides high availability through a primary and backup broker pair. The primary replicates its journal to the backup over the network, and the backup activates when it loses contact with the primary. Both brokers need a cluster connection to find each other, matching cluster credentials, and connectors that advertise addresses the other node can reach.

> [!NOTE]
> Replication with a single primary and backup pair cannot protect against split brain, a state in which both brokers are active at the same time. If the network between the two servers fails while both are running, the backup activates and both brokers accept messages independently. Artemis needs at least three primary and backup pairs for quorum voting to work. To protect a single pair, use a shared store or a pluggable lock manager backed by at least three ZooKeeper nodes. For details, see the [network isolation documentation](https://artemis.apache.org/components/artemis/documentation/latest/network-isolation.html).

1. Install Artemis on the second server with the same deployment method and administrator credentials you used on the primary server. Follow the steps in [Deploy Apache Artemis](#deploy-apache-artemis). The DNS record and HTTPS steps are optional on the backup server.

1. On the primary server, open the broker configuration file.

    * Docker:

        ```console
        $ sudo nano ~/artemis/data/etc/broker.xml
        ```

    * Standalone:

        ```console
        $ sudo nano /var/lib/artemis/etc/broker.xml
        ```

1. Add the following configuration inside the `<core>` section. Replace:

    * `PRIMARY_IP` with the IP address of the primary server that the backup can reach.
    * `BACKUP_IP` with the IP address of the backup server.
    * `CLUSTER_USER` and `CLUSTER_PASSWORD` with a cluster username and a strong password. Both brokers must use the same values.

    ```xml
    <connectors>
      <connector name="artemis">tcp://PRIMARY_IP:61616</connector>
      <connector name="backup">tcp://BACKUP_IP:61616</connector>
    </connectors>

    <cluster-user>CLUSTER_USER</cluster-user>
    <cluster-password>CLUSTER_PASSWORD</cluster-password>

    <ha-policy>
      <replication>
        <primary>
          <check-for-active-server>true</check-for-active-server>
        </primary>
      </replication>
    </ha-policy>

    <cluster-connections>
      <cluster-connection name="artemis-cluster">
        <connector-ref>artemis</connector-ref>
        <message-load-balancing>ON_DEMAND</message-load-balancing>
        <static-connectors>
          <connector-ref>backup</connector-ref>
        </static-connectors>
      </cluster-connection>
    </cluster-connections>
    ```

    Save and close the file.

    * `connectors`: The `artemis` connector is the address this broker advertises to the other node. The `backup` connector is the address of the other node.
    * `cluster-user` and `cluster-password`: Credentials that brokers use to authenticate cluster connections. The defaults are insecure placeholders and must be changed.
    * `check-for-active-server`: When the primary restarts after a failover, it checks for an active backup, synchronizes the latest data from it, and then takes over again. Without this setting, a restarted primary can serve messages that the backup already delivered.
    * `cluster-connection`: Connects the two brokers with static connectors so that they find each other without UDP multicast discovery.

1. On the backup server, open the broker configuration file with the same command.

1. Add the following configuration inside the `<core>` section. The connectors are reversed so that each broker advertises its own address.

    ```xml
    <connectors>
      <connector name="artemis">tcp://BACKUP_IP:61616</connector>
      <connector name="primary">tcp://PRIMARY_IP:61616</connector>
    </connectors>

    <cluster-user>CLUSTER_USER</cluster-user>
    <cluster-password>CLUSTER_PASSWORD</cluster-password>

    <ha-policy>
      <replication>
        <backup>
          <allow-failback>true</allow-failback>
        </backup>
      </replication>
    </ha-policy>

    <cluster-connections>
      <cluster-connection name="artemis-cluster">
        <connector-ref>artemis</connector-ref>
        <message-load-balancing>ON_DEMAND</message-load-balancing>
        <static-connectors>
          <connector-ref>primary</connector-ref>
        </static-connectors>
      </cluster-connection>
    </cluster-connections>
    ```

    Save and close the file.

    * `allow-failback`: The backup stops and returns to backup mode when the restarted primary asks to take over.

1. Restart the broker on the primary server first.

    * Docker:

        ```console
        $ docker compose restart artemis
        ```

    * Standalone:

        ```console
        $ sudo systemctl restart artemis
        ```

1. Restart the broker on the backup server with the same command.

1. View the broker log on the backup server to confirm replication.

    * Docker:

        ```console
        $ docker compose logs artemis
        ```

    * Standalone:

        ```console
        $ sudo tail -n 50 /var/lib/artemis/log/artemis.log
        ```

    The log contains a `backup announced` message and a message stating that the backup server is synchronized with the primary server.

1. Test failover. On the primary server, where you created the test scripts, set `SERVER_IP` to `PRIMARY_IP` in `amqp_send.py`, then send a message to the primary broker.

    ```console
    $ python3 ~/amqp-test/amqp_send.py
    ```

1. Stop the primary broker abruptly to simulate a crash. A graceful shutdown does not trigger failover by default.

    * Docker:

        ```console
        $ docker kill artemis
        ```

    * Standalone:

        ```console
        $ sudo systemctl kill --signal=SIGKILL artemis
        ```

        Then stop the unit so that systemd does not restart the primary during the test.

        ```console
        $ sudo systemctl stop artemis
        ```

1. View the broker log on the backup server again. The log contains the message `Backup Server is now active`.

1. On the primary server, set `SERVER_IP` to `BACKUP_IP` in `amqp_receive.py`, then receive the message from the backup broker.

    ```console
    $ python3 ~/amqp-test/amqp_receive.py
    ```

    The output displays `Received: Hello from Artemis`, which confirms that the backup holds the replicated message.

1. Start the primary broker again.

    * Docker:

        ```console
        $ docker compose start artemis
        ```

    * Standalone:

        ```console
        $ sudo systemctl start artemis
        ```

    The primary synchronizes with the active backup and takes over, and the backup returns to backup mode.

Configuration files such as `broker.xml`, `artemis-users.properties`, and `artemis-roles.properties` are not replicated. Apply every later configuration change on both servers. Configure clients with both broker addresses so they reconnect after a failover, for example `failover:(amqp://PRIMARY_IP:5672,amqp://BACKUP_IP:5672)` for Qpid JMS, or the `urls` list in Qpid Proton.

## Configure Security and Authentication

Both Docker and standalone installations create the administrator user automatically during setup and grant it full permissions on all addresses. Applications must not use the administrator account. Create separate users for publishers and consumers, and grant each role only the permissions it needs.

1. Open the users properties file.

    * Docker:

        ```console
        $ sudo nano ~/artemis/data/etc/artemis-users.properties
        ```

    * Standalone:

        ```console
        $ sudo nano /var/lib/artemis/etc/artemis-users.properties
        ```

1. Add users in the format `username=password`. The administrator user already exists.

    ```ini
    publisher=PUBLISHER_PASSWORD
    consumer=CONSUMER_PASSWORD
    ```

    Replace `PUBLISHER_PASSWORD` and `CONSUMER_PASSWORD` with strong passwords. Save and close the file.

1. Open the roles properties file.

    * Docker:

        ```console
        $ sudo nano ~/artemis/data/etc/artemis-roles.properties
        ```

    * Standalone:

        ```console
        $ sudo nano /var/lib/artemis/etc/artemis-roles.properties
        ```

1. Add a role for each new user in the format `role=user1,user2`. Keep the existing `amq` line, which belongs to the administrator.

    ```ini
    publishers=publisher
    consumers=consumer
    ```

    Save and close the file.

1. Open the broker configuration file.

    * Docker:

        ```console
        $ sudo nano ~/artemis/data/etc/broker.xml
        ```

    * Standalone:

        ```console
        $ sudo nano /var/lib/artemis/etc/broker.xml
        ```

1. Add the following `<security-setting>` block inside the existing `<security-settings>` section, before the catch-all `match="#"` block:

    ```xml
    <security-setting match="orders.#">
      <permission type="send" roles="amq,publishers"/>
      <permission type="consume" roles="amq,consumers"/>
      <permission type="browse" roles="amq,consumers"/>
      <permission type="createAddress" roles="amq"/>
      <permission type="deleteAddress" roles="amq"/>
      <permission type="createDurableQueue" roles="amq"/>
      <permission type="deleteDurableQueue" roles="amq"/>
      <permission type="createNonDurableQueue" roles="amq"/>
      <permission type="deleteNonDurableQueue" roles="amq"/>
    </security-setting>
    ```

    Save and close the file.

    * `match="orders.#"`: Applies to the `orders` address and every address that starts with `orders.`. Artemis uses the most specific match and does not merge permissions from broader matches, so the block lists the administrator role again.
    * `send`: Only the `publishers` role and the administrator can send.
    * `consume` and `browse`: Only the `consumers` role and the administrator can receive or browse.
    * `createAddress` and queue permissions: Only the administrator can create or delete addresses and queues, so create application addresses in advance through the web console or the `artemis queue create` command.

1. Restart the broker to apply the `broker.xml` changes.

    * Docker:

        ```console
        $ docker compose restart artemis
        ```

    * Standalone:

        ```console
        $ sudo systemctl restart artemis
        ```

1. Create an `orders` queue as the administrator so that the publisher has a destination.

    * Docker:

        ```console
        $ docker exec artemis /var/lib/artemis-instance/bin/artemis queue create \
            --name orders --address orders --anycast --durable \
            --preserve-on-no-consumers --auto-create-address --silent \
            --user ADMIN_USER --password ADMIN_PASSWORD --url tcp://localhost:61616
        ```

    * Standalone:

        ```console
        $ sudo -u artemis /var/lib/artemis/bin/artemis queue create \
            --name orders --address orders --anycast --durable \
            --preserve-on-no-consumers --auto-create-address --silent \
            --user ADMIN_USER --password ADMIN_PASSWORD --url tcp://localhost:61616
        ```

1. Verify the permissions. Set `USER` to `consumer` and `PASSWORD` to `CONSUMER_PASSWORD` in `amqp_send.py`, then send a message to `orders`.

    ```console
    $ python3 ~/amqp-test/amqp_send.py orders
    ```

    The script exits with an error because the `consumers` role does not have the `send` permission. Change the credentials to the `publisher` user and run the command again to confirm that the send succeeds.

## Set Up Dead-Letter Queues

Dead-letter queues (DLQs) capture messages that the broker cannot deliver within a configured number of attempts or that a consumer explicitly rejects. Dead-lettering prevents message loss and lets you troubleshoot delivery failures.

The default broker configuration routes undeliverable messages from every address to a single shared `DLQ` queue and expired messages to `ExpiryQueue`:

```xml
<address-setting match="#">
  <dead-letter-address>DLQ</dead-letter-address>
  <expiry-address>ExpiryQueue</expiry-address>
  <redelivery-delay>0</redelivery-delay>
  ...
</address-setting>
```

With these defaults, the broker redelivers a message immediately and moves it to the DLQ after 10 failed delivery attempts, because `max-delivery-attempts` defaults to `10`. Azure Service Bus keeps a separate dead-letter sub-queue for each queue and topic subscription. Enable automatic dead-letter resources to get a separate dead-letter queue for each address, and tune the retry settings.

1. Open the broker configuration file.

    * Docker:

        ```console
        $ sudo nano ~/artemis/data/etc/broker.xml
        ```

    * Standalone:

        ```console
        $ sudo nano /var/lib/artemis/etc/broker.xml
        ```

1. Locate the `<address-setting match="#">` block and add these elements inside it:

    ```xml
    <max-delivery-attempts>3</max-delivery-attempts>
    <redelivery-delay>5000</redelivery-delay>
    <redelivery-delay-multiplier>2.0</redelivery-delay-multiplier>
    <max-redelivery-delay>60000</max-redelivery-delay>
    <dead-letter-address>DLA</dead-letter-address>
    <auto-create-dead-letter-resources>true</auto-create-dead-letter-resources>
    ```

    Remove the existing `<dead-letter-address>DLQ</dead-letter-address>` and `<redelivery-delay>0</redelivery-delay>` lines from the same block so that each setting appears only once. Save and close the file.

    These settings control:

    * `max-delivery-attempts`: Number of delivery attempts before the broker moves the message to the dead-letter address.
    * `redelivery-delay`: Initial delay in milliseconds between retry attempts.
    * `redelivery-delay-multiplier`: Factor by which the delay increases with each retry.
    * `max-redelivery-delay`: Upper limit on the redelivery delay.
    * `dead-letter-address`: Sends dead letters to a new `DLA` address instead of the shared `DLQ` queue.
    * `auto-create-dead-letter-resources`: Creates the `DLA` address and, for each original address, a dedicated queue on it that filters on the original address. The queue name uses the default `DLQ.` prefix, so dead letters from `orders` land in the `DLQ.orders` queue on the `DLA` address.

1. **(Optional)** To send dead letters for specific addresses to a separate dead-letter address, define that address and its queue in the existing `<addresses>` section. A dead-letter address needs at least one queue to hold messages.

    ```xml
    <address name="CriticalDLQ">
      <anycast>
        <queue name="CriticalDLQ"/>
      </anycast>
    </address>
    ```

    Then add a new `<address-setting>` block before the catch-all `match="#"` block:

    ```xml
    <address-setting match="critical.#">
      <dead-letter-address>CriticalDLQ</dead-letter-address>
      <max-delivery-attempts>5</max-delivery-attempts>
      <redelivery-delay>1000</redelivery-delay>
      <auto-create-dead-letter-resources>false</auto-create-dead-letter-resources>
    </address-setting>
    ```

    Save and close the file.

1. Restart the broker to apply changes.

    * Docker:

        ```console
        $ docker compose restart artemis
        ```

    * Standalone:

        ```console
        $ sudo systemctl restart artemis
        ```

1. Test dead-lettering. Send a message to `test-queue` with the administrator credentials.

    ```console
    $ python3 ~/amqp-test/amqp_send.py test-queue
    ```

1. Receive the message and reject it. An AMQP rejection moves the message to the dead-letter address immediately.

    ```console
    $ python3 ~/amqp-test/amqp_receive.py test-queue reject
    ```

1. Receive the dead-lettered message from its dead-letter queue. The `DLA::DLQ.test-queue` value is a fully qualified queue name in the `address::queue` format.

    ```console
    $ python3 ~/amqp-test/amqp_receive.py DLA::DLQ.test-queue
    ```

    The output displays `Received: Hello from Artemis`, which confirms that the broker routed the rejected message to `DLQ.test-queue`.

## Configure Message Filtering and Routing

Artemis supports filters, which select messages by their headers and properties, and diverts, which move or copy messages from one address to another inside the broker without changing client code. These features replace Azure Service Bus subscription filters and auto-forwarding.

1. Open the broker configuration file.

    * Docker:

        ```console
        $ sudo nano ~/artemis/data/etc/broker.xml
        ```

    * Standalone:

        ```console
        $ sudo nano /var/lib/artemis/etc/broker.xml
        ```

1. Configure a divert to copy or redirect messages between addresses. Add the `<diverts>` block inside the `<core>` section.

    ```xml
    <diverts>
      <!-- Copy all high-priority messages to an audit queue -->
      <divert name="priority-audit">
        <address>orders</address>
        <forwarding-address>orders-audit</forwarding-address>
        <filter string="priority = 'high'"/>
        <exclusive>false</exclusive>
      </divert>

      <!-- Redirect all messages from legacy address to new address -->
      <divert name="legacy-redirect">
        <address>legacy-orders</address>
        <forwarding-address>orders</forwarding-address>
        <exclusive>true</exclusive>
      </divert>
    </diverts>
    ```

    In this configuration:

    * `filter`: Expression based on a subset of SQL-92 syntax that matches message headers and properties. The divert processes only matching messages.
    * `exclusive`: When `true`, the divert moves messages to the forwarding address instead of copying them.

1. **(Optional)** To create queues that hold only messages that match a filter, add them to the existing `<addresses>` section.

    ```xml
    <address name="notifications">
      <anycast>
        <queue name="email-notifications">
          <filter string="channel = 'email'"/>
        </queue>
        <queue name="sms-notifications">
          <filter string="channel = 'sms'"/>
        </queue>
      </anycast>
    </address>
    ```

    Save and close the file.

1. Restart the broker to apply changes.

    * Docker:

        ```console
        $ docker compose restart artemis
        ```

    * Standalone:

        ```console
        $ sudo systemctl restart artemis
        ```

## Monitor the Broker

Azure Monitor tracks queue depth, dead-letter counts, and errors for Service Bus automatically. A self-hosted broker needs the same visibility. Artemis reports queue statistics through its command-line tool and web console, and writes operational events to its log.

1. Display message counts, consumer counts, and delivery statistics for every queue.

    * Docker:

        ```console
        $ docker exec artemis /var/lib/artemis-instance/bin/artemis queue stat \
            --user ADMIN_USER --password ADMIN_PASSWORD --url tcp://localhost:61616
        ```

    * Standalone:

        ```console
        $ sudo -u artemis /var/lib/artemis/bin/artemis queue stat \
            --user ADMIN_USER --password ADMIN_PASSWORD --url tcp://localhost:61616
        ```

    The output displays a table with one row per queue and columns that include `CONSUMER_COUNT`, `MESSAGE_COUNT`, `MESSAGES_ADDED`, `DELIVERING_COUNT`, and `MESSAGES_ACKED`.

1. Watch dead-letter queues for growth. Add the `--queueName DLQ` option to the previous command to list only queues whose names contain `DLQ`, and the `--json` option to produce output that monitoring scripts can parse.

1. Review the broker log for warnings and errors.

    * Docker:

        ```console
        $ docker compose logs --tail 100 artemis
        ```

    * Standalone:

        ```console
        $ sudo tail -n 100 /var/lib/artemis/log/artemis.log
        ```

1. Monitor free disk space on the volume that holds the broker data directory. When disk usage exceeds the broker's `max-disk-usage` limit, the broker blocks producers by default.

    ```console
    $ df -h
    ```

To send metrics to an external monitoring system such as Prometheus, Artemis exports broker metrics through Micrometer and requires a metrics plugin. For details, see the [Artemis metrics documentation](https://artemis.apache.org/components/artemis/documentation/latest/metrics.html).

## Verify the Deployment

Validate the complete Artemis deployment by testing each component in turn.

1. Open `https://artemis.example.com/console` in a browser, log in with your administrator credentials, and confirm that the **Status** tab displays the broker version and uptime.

1. From a client machine, confirm that the AMQP port is reachable. Replace `SERVER_IP` with your server's IP address in this step and the next three steps, and skip any port you chose not to expose.

    ```console
    $ nc -zv SERVER_IP 5672
    ```

    The command reports that the connection succeeded.

1. Confirm that the Core and OpenWire port is reachable.

    ```console
    $ nc -zv SERVER_IP 61616
    ```

    The command reports that the connection succeeded.

1. Confirm that the STOMP port is reachable.

    ```console
    $ nc -zv SERVER_IP 61613
    ```

    The command reports that the connection succeeded.

1. Confirm that the MQTT port is reachable.

    ```console
    $ nc -zv SERVER_IP 1883
    ```

    The command reports that the connection succeeded.

1. Confirm that messages survive a broker restart. Send a message to `test-queue`.

    ```console
    $ python3 ~/amqp-test/amqp_send.py
    ```

1. Restart the broker.

    * Docker:

        ```console
        $ docker compose restart artemis
        ```

    * Standalone:

        ```console
        $ sudo systemctl restart artemis
        ```

1. Receive the message.

    ```console
    $ python3 ~/amqp-test/amqp_receive.py
    ```

    The output displays `Received: Hello from Artemis`, which confirms that the journal persisted the message across the restart.

1. Run the `artemis queue stat` command from [Monitor the Broker](#monitor-the-broker) and confirm that the `test-queue` row shows a `MESSAGE_COUNT` of `0` after the earlier tests consumed their messages.

## Migrate from Azure Service Bus to Apache Artemis

Migrating from Azure Service Bus to Artemis involves recreating entities, replacing the Azure SDK in each application, and planning for Service Bus features that Artemis implements differently or not at all.

### Queue and Topic Migration

Azure Service Bus queues map directly to Artemis anycast addresses, and topics with subscriptions map to multicast addresses.

* **Queues**: Create an anycast address in Artemis for each Azure Service Bus queue. Message ordering and competing consumer behavior are equivalent.
* **Topics and Subscriptions**: Create a multicast address for each topic. Each Azure subscription becomes a queue bound to the multicast address with an optional filter.

### AMQP Client Migration

Azure Service Bus and Artemis both use AMQP 1.0 on the wire, but the Azure Service Bus SDKs do not work against Artemis. The SDKs depend on Service Bus-specific extensions, including claims-based security (CBS) token authentication and the `$management` node for operations such as lock renewal and scheduling. Replace the Azure SDK with a generic AMQP 1.0 client such as [Apache Qpid JMS](https://qpid.apache.org/components/jms/index.html) for Java, [Apache Qpid Proton](https://qpid.apache.org/proton/index.html) for Python and C, [AMQP .NET Lite](https://github.com/Azure/amqpnetlite) for .NET, or [rhea](https://github.com/amqp/rhea) for Node.js.

The following Python example shows a producer before and after the migration.

* Before, with the Azure Service Bus SDK. `NAMESPACE_CONNECTION_STR` is your existing Service Bus connection string:

    ```python
    from azure.servicebus import ServiceBusClient, ServiceBusMessage

    with ServiceBusClient.from_connection_string(conn_str=NAMESPACE_CONNECTION_STR) as client:
        with client.get_queue_sender(queue_name="orders") as sender:
            sender.send_messages(ServiceBusMessage("Order 1001"))
    ```

* After, with Qpid Proton against Artemis. Replace `ARTEMIS_HOST` with the IP address or domain of your broker, and `PUBLISHER_PASSWORD` with the password of the `publisher` user:

    ```python
    from proton import Message
    from proton.utils import BlockingConnection

    conn = BlockingConnection("amqp://ARTEMIS_HOST:5672", user="publisher", password="PUBLISHER_PASSWORD")
    sender = conn.create_sender("orders")
    sender.send(Message(body="Order 1001"))
    conn.close()
    ```

Apply the same change to consumers. A Service Bus `complete_message` call becomes an AMQP accept, `abandon_message` becomes a release or modified outcome, and `dead_letter_message` becomes a reject.

* **Connection URL**: Replace the Service Bus connection string with the Artemis AMQP URL `amqp://host:5672`, and pass the username and password as client options. For TLS connections, configure a TLS acceptor on the broker and use `amqps://`.
* **Queue Addressing**: Azure uses `queue-name` or `topic-name/subscriptions/subscription-name`. Artemis uses the address name directly, or the `address::queue` format for fully qualified queue references.

### Message Session Migration

Azure Service Bus sessions provide ordered processing of related messages, a lock on each session, and per-session state storage. Artemis message grouping provides only the ordering part. The broker pins all messages with the same group ID to one consumer and delivers them in order. If that consumer disconnects, the broker assigns the group to another consumer.

1. Set the group ID on each message instead of the Service Bus `session_id`. AMQP clients set the standard `group-id` message property, which Artemis uses as the group ID. Java Message Service (JMS) clients set `JMSXGroupID`.

    ```python
    from proton import Message

    message = Message(body="Order 1001 step 1")
    message.group_id = "order-1001"
    ```

1. Keep the default `default-group-rebalance` setting of `false`. When rebalancing is enabled, the broker reassigns groups each time a consumer joins, which breaks the guarantee that a group stays with one consumer.

Artemis does not recommend message grouping across a cluster of active brokers, because grouped messages must be consumed serially, and clustered grouping routes every group decision through a grouping handler on a single node. For details, see the [Artemis message grouping documentation](https://artemis.apache.org/components/artemis/documentation/latest/message-grouping.html).

### Duplicate Detection

Azure Service Bus detects duplicates by `MessageId` within a configurable time window. Artemis detects duplicates only through the `_AMQ_DUPL_ID` message property and does not use the AMQP `message-id` field. It remembers a fixed number of recent IDs per address rather than IDs within a time window.

1. Verify or add duplicate detection settings in the `<core>` section of `broker.xml`.

    ```xml
    <id-cache-size>20000</id-cache-size>
    <persist-id-cache>true</persist-id-cache>
    ```

    * `id-cache-size`: Number of IDs the broker remembers for each address. The default is `20000`. Set a larger value if your duplicate window covers more messages than that.
    * `persist-id-cache`: Stores the cache in the journal so that it survives broker restarts. The default is `true`.

1. Restart the broker if you made changes.

    * Docker:

        ```console
        $ docker compose restart artemis
        ```

    * Standalone:

        ```console
        $ sudo systemctl restart artemis
        ```

1. Set the `_AMQ_DUPL_ID` application property on outgoing messages. AMQP clients can copy the value they previously used as the Service Bus `MessageId`.

    ```python
    from proton import Message

    message = Message(body="Order 1001")
    message.properties = {"_AMQ_DUPL_ID": "order-1001"}
    ```

    The broker drops a message whose ID is still in the cache for that address.

### Geo-Disaster Recovery

Azure Service Bus Premium replicates entities, and optionally messages, to a namespace in another region. The primary and backup pair in this article runs in one location. To replicate to a broker in another location, use AMQP broker connection mirroring. Mirroring sends messages and acknowledgements asynchronously, so the remote broker can lag behind the source.

Add the following block to the `<core>` section of the source broker. Replace `REMOTE_BROKER_IP`, `MIRROR_USER`, and `MIRROR_PASSWORD` with the address and credentials of the remote broker.

```xml
<broker-connections>
  <amqp-connection uri="tcp://REMOTE_BROKER_IP:5672" name="dr-site" user="MIRROR_USER" password="MIRROR_PASSWORD">
    <mirror/>
  </amqp-connection>
</broker-connections>
```

For bidirectional mirroring and failover guidance, see the [Artemis broker connections documentation](https://artemis.apache.org/components/artemis/documentation/latest/amqp-broker-connections.html).

### Features Without a Direct Equivalent

Some Azure Service Bus features have no Artemis counterpart. Redesign the parts of your applications that depend on them before you migrate.

* **Peek-lock with lock duration and renewal**: In Service Bus peek-lock mode, a receiver locks a message for a set duration so that other receivers cannot take it, and can renew the lock before it expires. Artemis holds an unacknowledged message for its consumer until the consumer settles it or disconnects. It has no lock timeout and no lock renewal operation.
* **Message deferral**: Artemis cannot set a message aside and retrieve it later by sequence number. Use a separate queue or scheduled delivery instead.
* **Session state**: Artemis cannot store state on a message group. Keep per-session state in an external database or cache.
* **Accepting a specific session**: A Service Bus receiver can request a named session or the next available session. Artemis assigns groups to consumers itself.
* **Microsoft Entra ID and managed identities**: Artemis authenticates with JAAS login modules such as properties files, LDAP, or client certificates.

### Data Storage Considerations

Azure Service Bus stores messages in Microsoft-managed, replicated storage. Artemis stores messages in its journal on the broker's local disk, so storage planning becomes your responsibility.

* **Disk Capacity**: Size the volume that holds the broker data directory for peak queue depth, including the paging directory that holds messages when memory limits are reached, and large messages.
* **Disk Performance**: The journal writes sequentially and syncs to disk on each durable write. Use SSD or NVMe storage for production workloads.
* **Backups**: Journal files are consistent only while the broker is stopped. For running brokers, rely on primary and backup replication or mirroring, or use the `artemis data exp` command to export message data while the broker is stopped.
* **Message Transfer**: No tool imports messages from Service Bus into Artemis. Switch producers to Artemis first, let existing consumers drain the Service Bus queues and subscriptions, and then switch consumers. Resubmit or archive messages left in Service Bus dead-letter queues.

### Things to Take Care During Migration

* **Credentials**: Azure Service Bus uses Shared Access Signature (SAS) tokens or Microsoft Entra ID authentication. Artemis uses username and password or certificate-based authentication. Update all client configurations with new credentials.
* **Naming Conventions**: Azure limits queue names to 260 characters with specific character restrictions. Artemis is more flexible, but avoid special characters for compatibility.
* **Message Properties**: Azure Service Bus custom properties map to AMQP application properties in Artemis. Standard properties such as `ContentType` and `CorrelationId` map to the AMQP `content-type` and `correlation-id` fields.
* **Scheduled Messages**: Azure Service Bus uses `ScheduledEnqueueTimeUtc`. AMQP clients schedule delivery in Artemis with the `x-opt-delivery-time` message annotation (a Unix timestamp in milliseconds) or the `x-opt-delivery-delay` annotation (a delay in milliseconds). Core and JMS clients use the `_AMQ_SCHED_DELIVERY` property.
* **Retry Policies**: Azure SDK retry policies do not carry over. Configure reconnect and retry settings in your AMQP client library.
* **Monitoring**: Replace Azure Monitor alerts with checks based on the `artemis queue stat` command, the web console, or a metrics plugin.
* **Dead-Letter Handling**: Service Bus creates a dead-letter sub-queue for every entity. Artemis uses one shared `DLQ` unless you enable `auto-create-dead-letter-resources`. Update consumers that read dead letters to use the new queue names.
* **Protocol**: Applications that still use the legacy Service Bus Messaging Protocol (SBMP) through the `WindowsAzure.ServiceBus` library must move to AMQP 1.0 regardless, because Microsoft ended SBMP support on September 30, 2026.

## Conclusion

You have deployed Apache Artemis as a self-hosted alternative to Azure Service Bus. This article covered Docker and standalone installations, HTTPS for the web console with Traefik and Nginx, a primary and backup broker pair with replication, message persistence tuning, AMQP connectivity testing, role-based security, per-address dead-letter handling, message filtering with diverts, basic monitoring, and the client changes needed to move applications off the Azure SDK. Before you move production traffic, test failover and recovery against your own workloads and add metrics export to your monitoring system. For more information, visit the [official Apache Artemis documentation](https://artemis.apache.org/components/artemis/documentation/).
