What s best way from java to delete a single Message in Queue

Robert
Robert Member Posts: 58 ✭✭
edited December 2021 in General Discussions #1

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?

Tagged:

Answers

  • amackenzie
    amackenzie Member, Employee Posts: 262 Solace Employee

    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 the msgId. It is this value that is the expected parameter for delete.

  • Robert
    Robert Member Posts: 58 ✭✭

    @amackenzie

    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.

  • amackenzie
    amackenzie Member, Employee Posts: 262 Solace Employee

    @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 using getNext(), 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 the browser.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.html

    Let us know how it goes.

  • Robert
    Robert Member Posts: 58 ✭✭

    @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. ;-)

  • amackenzie
    amackenzie Member, Employee Posts: 262 Solace Employee

    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.

  • Robert
    Robert Member Posts: 58 ✭✭

    I fully agree on that. I can imagine that people easy mix up the many different messagesId. :-)
    The key one is ApplicationMessageId which maps to JmsMessageId.