6.3. Managing AMQ Broker using the JMS API


The Java Message Service (JMS) API allows you to create, send, receive, and read messages. You can use JMS and the Red Hat build of Apache Qpid JMS client to manage brokers.

6.3.1. Configuring broker management using JMS messages and the Red Hat build of Apache Qpid JMS Client

To use JMS to manage a broker, you must first configure the broker’s management address with the manage permission.

Procedure

  1. Open the <broker_instance_dir>/etc/broker.xml configuration file.
  2. Add the <management-address> element, and specify a management address.

    By default, the management address is activemq.management. You only need to specify a different address if you do not want to use the default.

    <management-address>my.management.address</management-address>
  3. Provide the management address with the manage user permission type.

    This permission type enables the management address to receive and handle management messages.

    <security-setting-match="activemq.management">
        <permission-type="manage" roles="admin"/>
    </security-setting>

6.3.2. Managing brokers using the JMS API and Red Hat build of Apache Qpid JMS Client

To invoke management operations using JMS messages, the Red Hat build of Apache Qpid JMS client must instantiate the special management queue.

Procedure

  1. Create a QueueRequestor to send messages to the management address and receive replies.
  2. Create a Message.
  3. Use the helper class org.apache.activemq.artemis.api.jms.management.JMSManagementHelper to fill the message with the management properties.
  4. Send the message using the QueueRequestor.
  5. Use the helper class org.apache.activemq.artemis.api.jms.management.JMSManagementHelper to retrieve the operation result from the management reply.

例6.2 Viewing the number of messages in a queue

This example shows how to use the JMS API to view the number of messages in the JMS queue exampleQueue:

Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");

QueueSession session = ...
QueueRequestor requestor = new QueueRequestor(session, managementQueue);
connection.start();
Message message = session.createMessage();
JMSManagementHelper.putAttribute(message, "queue.exampleQueue", "messageCount");
Message reply = requestor.request(message);
int count = (Integer)JMSManagementHelper.getResult(reply);
System.out.println("There are " + count + " messages in exampleQueue");
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る