Search code examples
javajmxactivemq-artemis

How to send and subtract message to ActiveMQ Artemis queue via JMX?


I can't find any documentation anywhere on how to send and subtract a message to an ActiveMQ Artemis queue via JMX

I tried via the same MBean from ActiveMQ "Classic," but those MBeans are not intended to be used in ActiveMQ Artemis


Solution

  • You can find general information about the ActiveMQ Artemis management API in the documentation. To learn more about the various available management operations, see the Javadoc for these interfaces. They are located in the org.apache.activemq.artemis.api.core.management package and they are named with the word Control at the end (e.g. ServerControl, QueueControl, etc.).

    To send a message to a queue you can use the sendMessage() operation on the QueueControl or you could also use the same operation on the corresponding AddressControl and the message will be routed to the queues on the address according to the configured routing-type.

    By "subtract" I assume you mean delete and you can do that with a couple of different operations:

    • removeMessage(long) - Removes the message corresponding to the specified message ID. To be clear, this message ID is the internal ID, not the JMSMessageID. If you were browsing messages as we discussed in this question you could get this ID by looking at the "messageID" value (i.e. CompositeDataConstants#MESSAGE_ID)
    • removeMessage(String) - Removes all the message corresponding to the specified filter. Using null or an empty filter will remove all messages from this queue.