DEV Community

Cover image for Deploying ActiveMQ Artemis as a Self-Hosted Azure Service Bus Alternative
Sanskriti Harmukh for Vultr

Posted on with Aashish Chaurasiya Originally published at docs.vultr.com

Deploying ActiveMQ Artemis as a Self-Hosted Azure Service Bus Alternative

Azure Service Bus is Microsoft's fully managed enterprise message broker, providing queues, publish/subscribe topics, sessions, and dead-letter handling, but it ties workloads to Azure-specific SDKs and namespace-based pricing tiers. Apache Artemis is an open-source, multi-protocol message broker that runs on any infrastructure and natively supports AMQP 1.0 (the same protocol Service Bus exposes), along with MQTT, STOMP, OpenWire, and its own Core protocol. This guide deploys Artemis with Docker Compose behind Traefik for HTTPS, configures a primary and backup broker pair for high availability, secures the broker with roles, sets up dead-letter queues, message routing, and monitoring, and covers migrating application code from Azure Service Bus. By the end, you'll have a self-hosted, highly available Artemis broker that accepts AMQP 1.0 clients and a clear path for moving workloads off Azure Service Bus.


Understand the Artemis Architecture

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 (point-to-point), and an address with the MULTICAST routing type routes a copy of each message to every bound queue (publish/subscribe). The table maps each Service Bus construct to its Artemis counterpart:

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 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 AMQP broker connection mirroring Replication of messages to a broker in another location.

Prerequisites

  • A Linux server (at least 2 CPU cores and 4 GB of RAM) with a non-root user that has sudo privileges
  • (Optional) A second server if you want to configure high availability with a primary and backup broker pair
  • Docker and Docker Compose installed
  • A DNS A record that points a domain such as artemis.example.com to the public IP address of your server

Deploy Apache Artemis with Docker Compose

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

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:

$ sudo ufw allow 80,443/tcp
Enter fullscreen mode Exit fullscreen mode

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

$ mkdir -p ~/artemis/{data,letsencrypt}
Enter fullscreen mode Exit fullscreen mode
  • data: Persists the broker instance, including configuration and message storage.
  • letsencrypt: Stores Transport Layer Security (TLS) certificates.

3. Navigate to the project directory:

$ cd ~/artemis
Enter fullscreen mode Exit fullscreen mode

4. Create the .env file:

$ nano .env
Enter fullscreen mode Exit fullscreen mode

Replace artemis.example.com with your domain, admin@example.com with your email address, ADMIN_USER with your preferred administrator username, and ADMIN_PASSWORD with a strong password:

ARTEMIS_DOMAIN=artemis.example.com
ACME_EMAIL=admin@example.com
ARTEMIS_USER=ADMIN_USER
ARTEMIS_PASSWORD=ADMIN_PASSWORD
Enter fullscreen mode Exit fullscreen mode

5. Create the certificate storage file:

$ touch letsencrypt/acme.json
Enter fullscreen mode Exit fullscreen mode

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

$ chmod 600 letsencrypt/acme.json
Enter fullscreen mode Exit fullscreen mode

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

$ sudo chown -R 1001:1001 data
Enter fullscreen mode Exit fullscreen mode

8. Create the Docker Compose configuration file:

$ nano docker-compose.yml
Enter fullscreen mode Exit fullscreen mode
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
Enter fullscreen mode Exit fullscreen mode

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, used by applications migrating from Azure Service Bus.
  • Port 61613: STOMP for text-based messaging.
  • Port 1883: MQTT 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. EXTRA_ARGS binds the embedded web server to all container interfaces so Traefik can reach it, and disables strict origin checking for Jolokia (the bridge that converts HTTP requests into JMX operations, which the web console uses to 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.

9. Start the stack in detached mode:

$ docker compose up -d
Enter fullscreen mode Exit fullscreen mode

10. Verify the containers are running:

$ docker compose ps
Enter fullscreen mode Exit fullscreen mode

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

11. Check the Artemis startup logs for errors:

$ docker compose logs artemis
Enter fullscreen mode Exit fullscreen mode

The output shows the broker starting each acceptor and ends with a message that the server is now active.

12. 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:

$ nc -zv SERVER_IP 8161
Enter fullscreen mode Exit fullscreen mode

The connection fails or times out, confirming the console is reachable only through Traefik.

13. Open the Jolokia access configuration file. When Traefik terminates TLS, the browser sends an Origin header with the HTTPS scheme, but Artemis receives the request over plain HTTP internally. Jolokia rejects this scheme mismatch by default, which leaves the web console dashboard blank after login:

$ sudo nano ~/artemis/data/etc/jolokia-access.xml
Enter fullscreen mode Exit fullscreen mode

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

<cors>
    <allow-origin>*://0.0.0.0*</allow-origin>
    <!--ignore-scheme/-->
</cors>
Enter fullscreen mode Exit fullscreen mode

Replace *://0.0.0.0* with *://artemis.example.com* using your domain, and change <!--ignore-scheme/--> to <ignore-scheme/> so it becomes an active element. The section must look like this:

<cors>
    <allow-origin>*://artemis.example.com*</allow-origin>
    <ignore-scheme/>
</cors>
Enter fullscreen mode Exit fullscreen mode

15. Restart the Artemis container to apply the Jolokia configuration:

$ docker compose restart artemis
Enter fullscreen mode Exit fullscreen mode

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 https://artemis.example.com/console in a browser, replacing artemis.example.com with your domain.

2. Log in with the administrator credentials from your .env file. The Status tab shows the broker version, uptime, and HA policy.

3. Use the Addresses tab to view existing addresses (Artemis pre-creates DLQ and ExpiryQueue) and click Create Address to add one. Enter an address name such as orders and select Anycast for point-to-point or Multicast for publish/subscribe.

4. Use the Queues and Broker Diagram tabs to inspect queues and the broker topology.


Test AMQP Protocol Support

AMQP 1.0 is the protocol Azure Service Bus applications use, so it is the most important protocol to confirm. The default install pre-configures AMQP, STOMP, MQTT, and OpenWire acceptors.

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

$ 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
Enter fullscreen mode Exit fullscreen mode

2. Install the Python venv package:

$ sudo apt install python3-venv -y
Enter fullscreen mode Exit fullscreen mode

3. Create a Python virtual environment:

$ python3 -m venv ~/amqp-test
Enter fullscreen mode Exit fullscreen mode

4. Activate the virtual environment:

$ source ~/amqp-test/bin/activate
Enter fullscreen mode Exit fullscreen mode

5. Install the Apache Qpid Proton AMQP client library:

$ pip install python-qpid-proton
Enter fullscreen mode Exit fullscreen mode

6. Create a script that sends one message:

$ nano ~/amqp-test/amqp_send.py
Enter fullscreen mode Exit fullscreen mode

Replace SERVER_IP with the IP address of your broker, and ADMIN_USER and ADMIN_PASSWORD with your administrator credentials:

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()
Enter fullscreen mode Exit fullscreen mode

sender.send waits until the broker confirms it stored the message, and the script sends to test-queue unless you pass another address as the first argument.

7. Create a script that receives one message:

$ nano ~/amqp-test/amqp_receive.py
Enter fullscreen mode Exit fullscreen mode

Use the same SERVER_IP, ADMIN_USER, and ADMIN_PASSWORD values as the send script:

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()
Enter fullscreen mode Exit fullscreen mode

accept() removes the message from the queue, while passing reject as the second argument rejects it instead, which the dead-letter test uses later.

8. Send a test message:

$ python3 ~/amqp-test/amqp_send.py
Enter fullscreen mode Exit fullscreen mode

9. Receive the test message:

$ python3 ~/amqp-test/amqp_receive.py
Enter fullscreen mode Exit fullscreen mode

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.

1. Deploy Artemis on the second server. Repeat the Docker Compose deployment with the same administrator credentials. The DNS record and HTTPS steps are optional on the backup server.

2. On the primary server, open the broker configuration file:

$ sudo nano ~/artemis/data/etc/broker.xml
Enter fullscreen mode Exit fullscreen mode

3. Add the following configuration inside the <core> section. Replace PRIMARY_IP with the IP address of the primary server the backup can reach, BACKUP_IP with the IP address of the backup server, and CLUSTER_USER and CLUSTER_PASSWORD with a cluster username and a strong password (both brokers must use the same values):

<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>
Enter fullscreen mode Exit fullscreen mode
  • connectors: The artemis connector is the address this broker advertises to the other node, and backup is the address of the other node.
  • cluster-user and cluster-password: Credentials 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.
  • cluster-connection: Connects the two brokers with static connectors so they find each other without UDP multicast discovery.

4. On the backup server, open the same broker configuration file:

$ sudo nano ~/artemis/data/etc/broker.xml
Enter fullscreen mode Exit fullscreen mode

5. Add the following inside the <core> section. The connectors are reversed so each broker advertises its own address:

<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>
Enter fullscreen mode Exit fullscreen mode

allow-failback makes the backup stop and return to backup mode when the restarted primary asks to take over.

6. Restart the broker on the primary server first, then on the backup server:

$ docker compose restart artemis
Enter fullscreen mode Exit fullscreen mode

7. View the broker log on the backup server to confirm replication:

$ docker compose logs artemis
Enter fullscreen mode Exit fullscreen mode

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

8. 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:

$ python3 ~/amqp-test/amqp_send.py
Enter fullscreen mode Exit fullscreen mode

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

$ docker kill artemis
Enter fullscreen mode Exit fullscreen mode

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

11. Receive the message from the backup broker. On the primary server, set SERVER_IP to BACKUP_IP in amqp_receive.py, then run:

$ python3 ~/amqp-test/amqp_receive.py
Enter fullscreen mode Exit fullscreen mode

The output displays Received: Hello from Artemis, confirming the backup holds the replicated message.

12. Start the primary broker again:

$ docker compose start artemis
Enter fullscreen mode Exit fullscreen mode

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, so 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

The administrator user is created during setup with full permissions on all addresses. Applications must not use it. Create separate users for publishers and consumers, and grant each role only the permissions it needs.

1. Open the users properties file:

$ sudo nano ~/artemis/data/etc/artemis-users.properties
Enter fullscreen mode Exit fullscreen mode

2. Add users in the format username=password. The administrator already exists. Replace PUBLISHER_PASSWORD and CONSUMER_PASSWORD with strong passwords:

publisher=PUBLISHER_PASSWORD
consumer=CONSUMER_PASSWORD
Enter fullscreen mode Exit fullscreen mode

3. Open the roles properties file:

$ sudo nano ~/artemis/data/etc/artemis-roles.properties
Enter fullscreen mode Exit fullscreen mode

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

publishers=publisher
consumers=consumer
Enter fullscreen mode Exit fullscreen mode

5. Open the broker configuration file:

$ sudo nano ~/artemis/data/etc/broker.xml
Enter fullscreen mode Exit fullscreen mode

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

<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>
Enter fullscreen mode Exit fullscreen mode
  • 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, consume, and browse: Only the named roles (plus the administrator) can send, 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.

7. Restart the broker to apply the broker.xml changes:

$ docker compose restart artemis
Enter fullscreen mode Exit fullscreen mode

8. Create an orders queue as the administrator so the publisher has a destination:

$ 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
Enter fullscreen mode Exit fullscreen mode

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

$ python3 ~/amqp-test/amqp_send.py orders
Enter fullscreen mode Exit fullscreen mode

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 the send succeeds.


Set Up Dead-Letter Queues

Dead-letter queues (DLQs) capture messages the broker cannot deliver within a configured number of attempts, or that a consumer explicitly rejects. The default broker configuration routes undeliverable messages from every address to a single shared DLQ queue and expired messages to ExpiryQueue:

<address-setting match="#">
  <dead-letter-address>DLQ</dead-letter-address>
  <expiry-address>ExpiryQueue</expiry-address>
  <redelivery-delay>0</redelivery-delay>
  ...
</address-setting>
Enter fullscreen mode Exit fullscreen mode

By default the broker redelivers a message immediately and moves it to the DLQ after 10 failed delivery attempts (max-delivery-attempts). Azure Service Bus keeps a separate dead-letter sub-queue per queue and subscription, so enable automatic dead-letter resources to get a dedicated dead-letter queue per address.

1. Open the broker configuration file:

$ sudo nano ~/artemis/data/etc/broker.xml
Enter fullscreen mode Exit fullscreen mode

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

<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>
Enter fullscreen mode Exit fullscreen mode

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

  • max-delivery-attempts: Delivery attempts before the broker moves the message to the dead-letter address.
  • redelivery-delay, redelivery-delay-multiplier, max-redelivery-delay: Initial retry delay in milliseconds, the factor by which it grows each retry, and its upper limit.
  • 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 using the default DLQ. prefix, so dead letters from orders land in DLQ.orders on the DLA address.

3. Restart the broker to apply changes:

$ docker compose restart artemis
Enter fullscreen mode Exit fullscreen mode

4. Test dead-lettering. Send a message to test-queue with the administrator credentials:

$ python3 ~/amqp-test/amqp_send.py test-queue
Enter fullscreen mode Exit fullscreen mode

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

$ python3 ~/amqp-test/amqp_receive.py test-queue reject
Enter fullscreen mode Exit fullscreen mode

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

$ python3 ~/amqp-test/amqp_receive.py DLA::DLQ.test-queue
Enter fullscreen mode Exit fullscreen mode

The output displays Received: Hello from Artemis, confirming 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 replace Azure Service Bus subscription filters and auto-forwarding.

1. Open the broker configuration file:

$ sudo nano ~/artemis/data/etc/broker.xml
Enter fullscreen mode Exit fullscreen mode

2. Add a <diverts> block inside the <core> section to copy or redirect messages between addresses:

<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>
Enter fullscreen mode Exit fullscreen mode

filter is an expression based on a subset of SQL-92 syntax that matches message headers and properties, and exclusive set to true moves messages to the forwarding address instead of copying them.

3. Restart the broker to apply changes:

$ docker compose restart artemis
Enter fullscreen mode Exit fullscreen mode

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.

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

$ docker exec artemis /var/lib/artemis-instance/bin/artemis queue stat \
    --user ADMIN_USER --password ADMIN_PASSWORD --url tcp://localhost:61616
Enter fullscreen mode Exit fullscreen mode

The output displays one row per queue with columns that include CONSUMER_COUNT, MESSAGE_COUNT, MESSAGES_ADDED, DELIVERING_COUNT, and MESSAGES_ACKED. Add --queueName DLQ to list only dead-letter queues, and --json for output that monitoring scripts can parse.

2. Review the broker log for warnings and errors:

$ docker compose logs --tail 100 artemis
Enter fullscreen mode Exit fullscreen mode

3. 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:

$ df -h
Enter fullscreen mode Exit fullscreen mode

To export metrics to a system such as Prometheus, Artemis uses Micrometer and requires a metrics plugin. See the Artemis metrics documentation.


Verify the Deployment

1. Open the web console at https://artemis.example.com/console, log in, and confirm the Status tab displays the broker version and uptime.

2. Confirm the AMQP port is reachable from a client machine. Replace SERVER_IP with your server's IP address in this step and the next three, and skip any port you chose not to expose:

$ nc -zv SERVER_IP 5672
Enter fullscreen mode Exit fullscreen mode

3. Confirm the Core and OpenWire port is reachable:

$ nc -zv SERVER_IP 61616
Enter fullscreen mode Exit fullscreen mode

4. Confirm the STOMP port is reachable:

$ nc -zv SERVER_IP 61613
Enter fullscreen mode Exit fullscreen mode

5. Confirm the MQTT port is reachable:

$ nc -zv SERVER_IP 1883
Enter fullscreen mode Exit fullscreen mode

6. Confirm messages survive a broker restart. Send a message to test-queue:

$ python3 ~/amqp-test/amqp_send.py
Enter fullscreen mode Exit fullscreen mode

7. Restart the broker:

$ docker compose restart artemis
Enter fullscreen mode Exit fullscreen mode

8. Receive the message:

$ python3 ~/amqp-test/amqp_receive.py
Enter fullscreen mode Exit fullscreen mode

The output displays Received: Hello from Artemis, confirming the journal persisted the message across the restart. Run artemis queue stat again and confirm the test-queue row shows a MESSAGE_COUNT of 0.


Migrate from Azure Service Bus to Apache Artemis

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

1. Map queues and topics. Create an anycast address in Artemis for each Service Bus queue. For each topic, create a multicast address, and turn each subscription into a queue bound to it with an optional filter.

2. Replace the Azure SDK with a generic AMQP 1.0 client. Both use AMQP 1.0 on the wire, but the Azure SDKs depend on Service Bus-specific extensions such as claims-based security (CBS) token authentication and the $management node, so they do not work against Artemis. Use Apache Qpid JMS for Java, Apache Qpid Proton for Python and C, AMQP .NET Lite for .NET, or rhea for Node.js.

Before, with the Azure Service Bus SDK (NAMESPACE_CONNECTION_STR is your existing connection string):

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"))
Enter fullscreen mode Exit fullscreen mode

After, with Qpid Proton against Artemis (replace ARTEMIS_HOST with the IP address or domain of your broker, and PUBLISHER_PASSWORD with the publisher user's password):

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()
Enter fullscreen mode Exit fullscreen mode

Apply the same change to consumers: complete_message becomes an AMQP accept, abandon_message becomes a release or modified outcome, and dead_letter_message becomes a reject. Azure uses queue-name or topic-name/subscriptions/subscription-name addressing, while Artemis uses the address name directly, or the address::queue format for fully qualified queue references. For TLS connections, configure a TLS acceptor on the broker and use amqps://.

3. Replace sessions with message grouping. Artemis pins all messages with the same group ID to one consumer and delivers them in order, but provides no session lock or session state. Set the standard group-id message property instead of the Service Bus session_id (JMS clients set JMSXGroupID), and keep the default default-group-rebalance setting of false:

from proton import Message

message = Message(body="Order 1001 step 1")
message.group_id = "order-1001"
Enter fullscreen mode Exit fullscreen mode

4. Configure duplicate detection. Artemis detects duplicates only through the _AMQ_DUPL_ID message property, remembering a fixed number of recent IDs per address rather than a time window. Verify or add these settings in the <core> section of broker.xml, then restart the broker:

<id-cache-size>20000</id-cache-size>
<persist-id-cache>true</persist-id-cache>
Enter fullscreen mode Exit fullscreen mode

Set _AMQ_DUPL_ID on outgoing messages, reusing the value you previously used as the Service Bus MessageId:

from proton import Message

message = Message(body="Order 1001")
message.properties = {"_AMQ_DUPL_ID": "order-1001"}
Enter fullscreen mode Exit fullscreen mode

5. (Optional) Replicate to a broker in another location. The primary and backup pair runs in one location. For geo-disaster recovery, use AMQP broker connection mirroring, which sends messages and acknowledgements asynchronously, so the remote broker can lag behind. Add this to the <core> section of the source broker, replacing REMOTE_BROKER_IP, MIRROR_USER, and MIRROR_PASSWORD with the remote broker's address and credentials:

<broker-connections>
  <amqp-connection uri="tcp://REMOTE_BROKER_IP:5672" name="dr-site" user="MIRROR_USER" password="MIRROR_PASSWORD">
    <mirror/>
  </amqp-connection>
</broker-connections>
Enter fullscreen mode Exit fullscreen mode

Plan around features that have no direct Artemis equivalent:

  • Peek-lock with lock duration and renewal: Artemis holds an unacknowledged message for its consumer until it settles or disconnects, with no lock timeout or renewal.
  • Message deferral: Use a separate queue or scheduled delivery instead.
  • Session state: Keep per-session state in an external database or cache.
  • Microsoft Entra ID and managed identities: Artemis authenticates with JAAS login modules such as properties files, LDAP, or client certificates.
  • Storage: Artemis stores messages in a local journal, so size disk capacity for peak queue depth, use SSD or NVMe storage, and rely on replication or mirroring rather than file copies for backups.
  • Message transfer: No tool imports messages from Service Bus. Switch producers to Artemis first, let existing consumers drain the Service Bus entities, then switch consumers.
  • Scheduled messages: AMQP clients use the x-opt-delivery-time (Unix timestamp in milliseconds) or x-opt-delivery-delay annotation, and Core and JMS clients use the _AMQ_SCHED_DELIVERY property.

Next Steps

Artemis is running behind HTTPS with replication, role-based security, and dead-letter handling. From here you can:

  • Add a TLS acceptor and switch clients to amqps:// to encrypt broker traffic
  • Export broker metrics to Prometheus with the Artemis Micrometer metrics plugin
  • Move to a shared store or ZooKeeper-backed lock manager to protect the primary and backup pair from split brain
  • Test failover and recovery against your own workloads before moving production traffic

For the full guide with additional tips, visit the original article on Vultr Docs.

Top comments (0)