🎄 Happy Holidays! 🥳
Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.
Happy Holidays!
Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.
What s best way from java to delete a single Message in Queue
I use JSCMP queue. browser to loom up message inside a queue.
Now i want to delete. some of this msssages and look for best way to do so.
Is there a way via JSCMP?
via SEMP i found that:
https://docs.solace.com/API-Developer-Online-Ref-Documentation/swagger-ui/action/index.html#/queue
I was surprised a PUT was used for delete but main question here is what is meant my messageId?
There is a ApplicationMessageId which turns. for Jms into MessageId but that is not mandatory to be set. So which message id is meant and how. to retrieve that from message object retrieved queueBrowser?
Answers
-
There is a
msgId
which is internal to PubSub+ (the broker handles it entirely and you cannot set it) which identifies the message.
In/msgVpns/{msgVpnName}/queues/{queueName}/msgs
you can get a list of messages and part of the data returned in the list will be themsgId
. It is this value that is the expected parameter for delete.1 -
I found it already on jcsmp lib:
msg.getMessageId(); BUT......
https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/XMLMessage.html#getMessageId--But my problem is that this got now deprecated. So how should i find the internal message id in future to pass over to SEMP to delete it when i can not fetch it any longer ?
Here deprecation info:
_"The message ID is only to be used for the purpose of acknowledgements. No other meaning should be inferred from the value of the guaranteed message ID."I feel nobody considered that people have to use different libs, apis to do certain things as functionality is consistent around the libs and apis.
I use e.g. jcsmp queue browser to look up and show in a grid and then i want to select specific messages (check box) to remove from e.g. queue. So i need from jcsmp the messageId (still possible
but deprecated) and go over to use semp API to remove the message by passing over.0 -
@Robert the queue browser is different than just a normal consumer. It has its own set of methods, etc. and is essentially an iterator.
So the way you would accomplish your use case is:
1. Set up your queue browser
2. Populate your checkbox table UI by iterating through the browser usinggetNext()
, while maintaining message info in your code so you can reference specific messages later.
3. When someone picks the message(s) using checkmark(s), issue thebrowser.remove(msgRef)
to delete from queue (and you should probably remove it from your reference list)There are some code samples/docs that might help:
https://docs.solace.com/Solace-PubSub-Messaging-APIs/API-Developer-Guide/Browsing-Guaranteed-Mess.htm
https://tutorials.solace.dev/jcsmp/browsing-queues/
https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/Browser.htmlLet us know how it goes.
0 -
@amackenzie you are the best i will look into that. At least i would not need then the getMessageId.
I still think Solace should re-think to remove that function if APIs make use if that ID. ;-)0 -
It's deprecated but unlikely to be removed. What we don't want is for people to use it as a persistent, globally unique ID that becomes external. It is not and is mostly internal so we discourage it's use by app devs.
0