此内容没有您所选择的语言版本。

28.3. Using Management Via Core API


The core management API in HornetQ is called by sending core messages to the management address.
Management messages are regular core messages with well-known properties that the server needs to understand to interact with the management API:
  • The name of the managed resource
  • The name of the management operation
  • The parameters of the management operation
When a management message is sent to the management address, HornetQ processes the message in the following way:
  • extracts the information
  • invokes the operation on the managed resources
  • sends a management reply to the management message's reply-to address.
The management reply sent to the reply-to address is controlled by the org.hornetq.core.client.impl.ClientMessageImpl.REPLYTO_HEADER_NAME parameter.
A ClientConsumer can be used to consume the management reply and retrieve the result of the operation (if any) stored in the body of the reply. For portability, results are returned as a JSON string rather than Java Serialization. The org.hornetq.api.core.management.ManagementHelper can be used to convert the JSON string to Java objects.
These steps can be simplified to make it easier to invoke management operations using Core messages:

Procedure 28.1. Invoking Management Operations

  1. Step One

    Create a ClientRequestor to send messages to the management address and receive replies
  2. Step Two

    Create a ClientMessage
  3. Step Three

    Use the helper class org.hornetq.api.core.management.ManagementHelper to fill the message with the management properties.
  4. Step Four

    Send the message using the ClientRequestor
  5. Step Five

    Use the helper class org.hornetq.api.core.management.ManagementHelper to retrieve the operation result from the management reply.
For example, to find out the number of messages in the core queue exampleQueue:
   ClientSession session = ...
   ClientRequestor requestor = new ClientRequestor(session, "jms.queue.hornetq.management");
   ClientMessage message = session.createMessage(false);
   ManagementHelper.putAttribute(message, "core.queue.exampleQueue", "messageCount");
   ClientMessage reply = requestor.request(m);
   int count = (Integer) ManagementHelper.getResult(reply);
   System.out.println("There are " + count + " messages in exampleQueue");
Copy to Clipboard Toggle word wrap
Management operation name and parameters must conform to the Java interfaces defined in the management packages.
Names of the resources are built using the helper class org.hornetq.api.core.management.ResourceNames and are straightforward (core.queue.exampleQueue for the Core Queue exampleQueue, jms.topic.exampleTopic for the JMS Topic exampleTopic, and so on).

28.3.1. Configuring Core Management

The management address to send management messages is configured in <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml:
<management-address>jms.queue.hornetq.management</management-address>
Copy to Clipboard Toggle word wrap
By default, the address is jms.queue.hornetq.management (it is prepended by "jms.queue" so that JMS clients can also send management messages).
The management address requires a special user permission manage to be able to receive and handle management messages. This is also configured in <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml:
<!-- users with the admin role will be allowed to manage --> 
<!-- HornetQ using management messages        -->
<security-setting match="jms.queue.hornetq.management">
   <permission type="manage" roles="admin" />
</security-setting>
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat