是的,ActiveMQ Artemis支持从ActiveMQ.Advisory.Queue中获取消息。以下是一个使用Java API的示例代码:
import javax.jms.*;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
public class AdvisoryQueueConsumer {
public static void main(String[] args) throws Exception {
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue advisoryQueue = session.createQueue("ActiveMQ.Advisory.Queue");
MessageConsumer consumer = session.createConsumer(advisoryQueue);
consumer.setMessageListener(new MessageListener() {
public void onMessage(Message message) {
System.out.println("Received message: " + message);
}
});
}
}
该示例在ActiveMQ.Advisory.Queue上创建一个消息消费者,当在该队列上发布新的消息时,消费者将收到通知并打印接收到的消息。