Reputation: 7792
I have Apache ActiveMQ "Classic" embedded into my Java 8 server-side project. Its working fine, and I am able to send and consume messages from pre-configured queues. I now need to be able programatically remove messages from the queue upon request. After reading some docs I found that Apache ActiveMQ has a sub-project called ActiveMQ Artemis that seems to provide the required functionality, but I am a bit confused on how to do it. Is Artemis sort of plugin on top of ActiveMQ "Classic" and I just need to add required dependencies and use the tools or is it a separate product and it doesn't work with ActiveMQ "Classic" but instead as an independent product. If so how do I manage individual messages (in particular delete requested message) in ActiveMQ "Classic"?
Upvotes: 0
Views: 1047
Reputation: 18356
First off, 'ActiveMQ Artemis' is a sub-project within the ActiveMQ project that represents an entirely new broker with a radically different underlying architecture than the main ActiveMQ broker. You would run one or the other.
To manage messages in the ActiveMQ broker you would use the JMX Mamagement API and the Queue#remove methods it exposes to remove specific messages. This can be done using the Message ID or more broadly using a message selector to capture more than one message if need be. The JMX API is also exposed via Jolokia so that you can manage the broker via simple REST calls instead of the JMX way if you prefer.
In any case this sort of message level management on the broker is a bit of an anti-pattern in the messaging world. If you find yourself needing to treat the broker as a database then you should ask yourself why you aren't using a database since a broker is not a database. Often you will run into many more issues trying to manage your messages this way as opposed to just putting them into a database.
Upvotes: 1