I am coding with c# and activemq, using NMS 1.6.1 and ActiveMQ 5.9. I want to set a unique guid in custom property for each message when I send it, then I can delete a specific message with by its guid(NOT purge a queue, only delete one message in it). Since I did not find any NMS api that could help, I think calling activemq jmx api is the only way.
At first I want to use IKVM to help me, but it did not work fine. The ActiveMQ official site says that "Starting with version 5.8 we provide a REST management API for the broker. Using Jolokia JMX-HTTP bridge it's possible to access all broker metrics (like memory usage) and execute management operations (like purging queues) using REST API."
Since I am using c# , can I access these REST management api easily ?Can these REST management api solve my problem ? Or is there any easier way ?
0
votes
1 Answers
1
votes
You should be able to create a consumer with a selector set to your GUID to delete the specific message. For example:
ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
IMessageConsumer consumer = session.CreateConsumer(destination, string.Format("CustomProperty = '{0}'", msgGUID));
IMessage msg = consumer.Receive();
This will consume the single message and remove it from the queue. I don't think the JMX REST API is necessary.