How to browse an Artemis queue under different address using JMS and CORE protocol?

I am trying to browse a queue on Apache ActiveMQ Artemis using a JMS QueueBrowser, but the name of the queue is different from the name of the address it is created under. For example: automatically created expiry or deadletter queues under a single address. I have replicated the problem in the scenario and code described below:

Create an address with name “address” and create a queue with name “queue”. Send a couple simple text messages to the queue. This will result in a situation like this:

Now use the following code to browse through the queue and print the messages:

import java.util.Collections;
import java.util.List;

import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueBrowser;
import javax.jms.Session;

import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;

public class ArtemisQueueBrowser {
    
    public static void main(String[] args) throws JMSException {
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
        Connection connection = connectionFactory.createConnection("admin", "admin");
        connection.start();
        Session session = connection.createSession();
        Queue queue = session.createQueue("queue");
        QueueBrowser browser = session.createBrowser(queue);
        
        List<Message> messages = Collections.list(browser.getEnumeration());
        
        System.out.println(messages.size() + " messages:");
        for (Message message : messages) {
            System.out.println("- "  + message.getBody(String.class));
        }
        connection.close();
    }
}

This should print the message bodies as a list, but instead exits with the following error:

ActiveMQQueueExistsException[errorType=QUEUE_EXISTS message=AMQ229019: Queue queue already exists on address address]

It looks like either the CORE client or the server fails to find the queue and tries to create it under an address with the samen name as the queue. This fails of course since the queue already exists.

But it gets stranger! Because if I try the same thing using an AMQP connection factory the behaviour is different! I use the following (almost identical, hurray JMS) code:

import java.util.Collections;
import java.util.List;

import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueBrowser;
import javax.jms.Session;

import org.apache.qpid.jms.JmsConnectionFactory;

public class AmqpQueueBrowser {
    
    public static void main(String[] args) throws JMSException {
        JmsConnectionFactory connectionFactory = new JmsConnectionFactory("amqp://localhost:61616");
        Connection connection = connectionFactory.createConnection("admin", "admin");
        connection.start();
        Session session = connection.createSession();
        Queue queue = session.createQueue("testqueue");
        QueueBrowser browser = session.createBrowser(queue);
        
        List<Message> messages = Collections.list(browser.getEnumeration());
        
        System.out.println(messages.size() + " messages:");
        for (Message message : messages) {
            System.out.println("- "  + message.getBody(String.class));
        }
        connection.close();
    }
}

The output is:

[AmqpProvider :(1):[amqp://localhost:61616]] INFO org.apache.qpid.jms.JmsConnection - Connection ID:9e10c2c8-00c0-4e59-9401-9b0a53f40f49:1 connected to server: amqp://localhost:61616
3 messages:
- 1st message
- second message
- and another message just for good measure

Now the output is correct, but Artemis incorrectly created a new address with the name “queue” with no queues associated, while the QueueBrowser reads the queue under address “address”:

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật